コード例 #1
0
ファイル: myapp.py プロジェクト: ad1lkhan/ccproject
import json


class MessageForm(FlaskForm):
    message = TextField(u'Enter team name',
                        [validators.optional(),
                         validators.length(max=200)])


app = Flask(__name__)
app.secret_key = '0e9490ae2c4e4915aa88fe0fc509d35b'

nav = Navigation(app)

nav.Bar('top',
        [nav.Item('Home!', 'index'),
         nav.Item('Premier League', 'team')])


@app.route('/')
@app.route('/index/')
def index():
    return render_template("index.html")


@app.route('/team/', methods=['GET', 'POST'])
def team():
    form = MessageForm(request.form)
    if request.method == 'POST':
        msg = form.message.data
        connection = http.client.HTTPConnection('api.football-data.org')
コード例 #2
0
from app import app
from flask import render_template, request
import unirest
from forms import MessageForm
from flask_navigation import Navigation

nav = Navigation(app)

nav.Bar('top', [nav.Item('Home', 'index'), nav.Item('Emotion App', 'emotion')])


@app.route('/')
@app.route('/index/')
def index():
    return render_template("index.html")


@app.route('/emotion/')
def emotion():
    return render_template("my_form.html", mood='happy', form=MessageForm())


@app.route('/emotion/', methods=['POST'])
def emotion_post():
    msg = request.form['message']
    response = unirest.post(
        "https://community-sentiment.p.mashape.com/text/",
        headers={
            "X-Mashape-Key":
            "6VWQcE5umumsh9oLsHfFlOseFGbDp1caaUKjsnj6PJRqxZKslv",
            "Content-Type": "application/x-www-form-urlencoded",
コード例 #3
0
from flask import Flask
from flask_navigation import Navigation

app = Flask(__name__)

nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Flower fields', 'fields'),
    nav.Item('About', 'about'),
    nav.Item('Contact', 'contact')
])

from app import routes
コード例 #4
0
from flask import jsonify, request, render_template, redirect, url_for

from proj_flask import app

# define a navigation bar
#pip install Flask-Navigation
#https://flask-navigation.readthedocs.io/en/latest/
from flask_navigation import Navigation
nav = Navigation()
nav.init_app(app)
nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Posts', 'url_posts'),
    nav.Item('Redirect', 'url_redirect'),
    nav.Item('URL Query', 'url_query', {'scope': 'USA'}),
    nav.Item('JSON', 'url_json'),
    nav.Item('Static', 'url_static'),
    nav.Item('XML', 'url_xml'),
])

# Get the content from topics.xml file
from proj_flask.class_xml_topics import XmlTopics
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class_file_path = os.path.join(basedir, 'static/xml/topics.xml')

data_json = {
    "chartData": {
        "labels": [
        "sunday",
コード例 #5
0
from flask_navigation import Navigation
from config import (PREFIX, ELECTRA_API_ADDRESS, API_CERT_LOC)
from utils import create_token_header
import requests as r
import json

app = Flask(__name__)
app.config['SECRET_KEY'] = 'askjfalkfbglhubvfliusdbg'
app.config['TEMPLATES_AUTO_RELOAD'] = True
app.config['STATIC_AUTO_RELOAD'] = True

nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Αρχική σελίδα', 'index'),
    nav.Item('Ο λογαριασμός μου', 'account'),
    nav.Item('Υπηρεσίες χρέωσης', 'billing'),
    nav.Item('Επικοινωνία', 'contact')
])

dataset_dict = {
    'ActualTotalLoad': 'Actual Total Load',
    'AggregatedGenerationPerType': 'Aggregated Generation Per Type',
    'DayAheadTotalLoadForecast': 'Day-Ahead Total Load Forecast',
    'ActualvsForecast': 'Actual Total Load vs Day-Ahead Total Load Forecast'
}
res_dict = {'PT15M': '15 λεπτά', 'PT30M': '30 λεπτά', 'PT60M': '60 λεπτά'}
prodtypes = [
    'Fossil Gas', 'Hydro Run-of-river and poundage', 'Hydro Pumped Storage',
    'Hydro Water Reservoir', 'Fossil Hard coal', 'Nuclear',
    'Fossil Brown coal/Lignite', 'Fossil Oil', 'Fossil Oil shale', 'Biomass',
    'Fossil Peat', 'Wind Onshore', 'Other', 'Wind Offshore',
コード例 #6
0
ファイル: routes.py プロジェクト: Adlef/MyWepApp
from myapp import app
import json, plotly
from flask import render_template, request
from wrangling_scripts.WorldHappiness.wrangle_data_happiness import return_figures
from wrangling_scripts.DisasterMessages.disasters_messages import *
from flask_navigation import Navigation

nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Happiness in the World', 'happiness'),
    nav.Item('Disaster Messages Classification', 'disasters_1_2'),
])


@app.route('/')
@app.route('/happiness')
def happiness():

    figures = return_figures()

    # plot ids for the html id tag
    ids = ['figure-{}'.format(i) for i, _ in enumerate(figures)]

    # Convert the plotly figures to JSON for javascript in html template
    figuresJSON = json.dumps(figures, cls=plotly.utils.PlotlyJSONEncoder)

    return render_template('happiness.html', ids=ids, figuresJSON=figuresJSON)


graphs, model, df = return_figures_disaster()
コード例 #7
0
ファイル: __init__.py プロジェクト: stolucc/sesame
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile("../config.py")

    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    nav = Navigation(app)

    # Navbar visible to all
    nav.Bar('top', [
        nav.Item('Home', 'auth.home'),
        nav.Item('Calls For Proposals', 'call_system.view_all_calls'),
        nav.Item('Register', 'auth.register'),
        nav.Item('Login', 'auth.login')
    ])

    # Navbar for logged in users (researchers)
    nav.Bar('user', [
        nav.Item('Home', 'auth.home'),
        nav.Item('Profile', 'profile.view'),
        nav.Item('Calls For Proposals', 'call_system.view_all_calls'),
        nav.Item('Logout', 'auth.logout')
    ])

    # Navbar for logged in admins
    nav.Bar('admin', [
        nav.Item('Home', 'admin.dashboard'),
        nav.Item('Calls For Proposals', 'admin.allCalls'),
        nav.Item('Make CFP', 'call_system.make_call'),
        nav.Item('Logout', 'auth.logout')
    ])

    # Navbar for logged in reviewers
    nav.Bar(
        'reviewer',
        [
            nav.Item('Home', 'auth.home'),
            nav.Item('Calls For Proposals', 'call_system.view_all_calls'),
            #nav.Item('Proposal Submissions', 'call_system.view_proposal_submissions'),
            nav.Item('Logout', 'auth.logout')
        ])
    nav.Bar('researcher', [
        nav.Item('Home', 'auth.home'),
        nav.Item('Calls For Proposals', 'call_system.view_all_calls'),
        nav.Item('Proposal Submissions',
                 'call_system.researcher_view_initial_pending_submissions'),
        nav.Item('Logout', 'auth.logout')
    ])

    from app.auth import auth
    app.register_blueprint(auth, url_prefix="/auth/")
    from app.profile import profile
    app.register_blueprint(profile, url_prefix="/profile/")
    from app.call_system import call_system
    app.register_blueprint(call_system, url_prefix="/calls/")
    from app.admin import admin
    app.register_blueprint(admin, url_prefix="/admin/")
    from app.reviewer import reviewer
    app.register_blueprint(reviewer, url_prefix="/reviewer/")

    with app.app_context():
        db.create_all()

    configure_uploads(app, programme_docs)
    configure_uploads(app, proposal_templates)

    from app import commands
    app.cli.add_command(commands.db_cli)
    app.cli.add_command(commands.user_cli)

    from app import jinja_filters
    app.jinja_env.filters["whatInput"] = jinja_filters.whatInput

    return app
コード例 #8
0
ファイル: frontseat.py プロジェクト: ax-rwnd/lounge-frontseat
# setup flask
app = Flask(__name__)
app.secret_key = config.secret_key
oid = OpenID(app)

# setup flask navigation
nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Search', 'search'),
    nav.Item('Browse', 'browse'),
    nav.Item('Playlists', 'playlist'),
    nav.Item('Info', 'info', items=[
        nav.Item('About', 'about'),
        nav.Item('Contact', 'contact'),
    ]),
    nav.Item('Profile', 'profile', items=[
        nav.Item('Settings', 'settings'),
	nav.Item('Friends', 'users'),
        nav.Item('Signout', 'signout'),
    ]),
])


def login_required(f):
    """ Checks that the user is logged in before proceeding to the requested page. """

    @wraps(f)
    def decorated_function(*args, **kwargs):
        data = {"username": session.get('user', ''), "session": session.get('session', '')}
コード例 #9
0
from flask import Blueprint, render_template, abort, request, flash, redirect, url_for
from jinja2 import TemplateNotFound
from flask_login import login_required
from flask_navigation import Navigation
from forms import AddBookForm
from app import models
import isbnlib

admin_page = Blueprint('admin_page',
                       __name__,
                       template_folder='templates/admin')

admin_nav = Navigation()
admin_nav.Bar('top', [
    admin_nav.Item('Dashboard', 'admin_page.index'),
    admin_nav.Item('Public', 'index'),
    admin_nav.Item('Logout', 'logout')
])

admin_nav.Bar('left', [
    admin_nav.Item('Overview', 'admin_page.index'),
    admin_nav.Item('Books', 'admin_page.books'),
    admin_nav.Item('Authors', 'admin_page.index'),
    admin_nav.Item('Users', 'admin_page.index'),
])


@admin_page.route('/')
@admin_page.route('/index')
@login_required
def index():
コード例 #10
0
from werkzeug.security import generate_password_hash, check_password_hash

#this library functions are imported to generate encrypted passwords the last one
#without the last one can also be done but password will be visible

#Configuring all the Flask Values to connect database and bootstrap
app = Flask(__name__)
app.config['SECRET_KEY'] = 'Mysecretkey123'
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'sqlite://///home/subhro/Desktop/FlaskProject/database.db'
Bootstrap(app)
nav = Navigation(app)
db = SQLAlchemy(app)

#Create a Navigation Bar
nav.Bar('top', [nav.Item('Home', 'index')])
#initializing the login_managerwith the app
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'


#setting up a decorator
@login_manager.user_loader
def load_user(user_id):
    return User.query.get(int(user_id))


#Create a db Model/Table as ORM as in SQL for Users and using UserMixin to get full functionality of flask Login'''
class User(UserMixin, db.Model):
    id = db.Column(db.Integer, primary_key=True)
コード例 #11
0
nav = Navigation(app)

# Navigation
nav.Bar('top', [
    nav.Item('Today\'s devotion',
             'devotion_controller',
             html_attrs={
                 'class': ['main-nav-target', 'mod-devotion'],
                 'role': 'menuitem'
             }),
    nav.Item('Find Schools',
             'type_locator_controller', {'search_type': 'school'},
             html_attrs={
                 'class': ['main-nav-target', 'mod-school'],
                 'role': 'menuitem'
             }),
    nav.Item('Find Churches',
             'type_locator_controller', {'search_type': 'church'},
             html_attrs={
                 'class': ['main-nav-target', 'mod-church'],
                 'role': 'menuitem'
             }),
    nav.Item('Goods & Services',
             'connector_controller',
             html_attrs={
                 'class': ['main-nav-target', 'mod-store'],
                 'role': 'menuitem'
             }),
])

nav.Bar('admin', [
    nav.Item('Venues', 'venue_manager', html_attrs={'class': ['target']}),
コード例 #12
0
from app import app
from flask import render_template, request
import unirest
from forms import MessageForm
import database
from flask_navigation import Navigation
from app import simple

nav = Navigation(app)

nav.Bar(
    'top',
    [
        nav.Item('Home', 'index'),
        nav.Item('Emotion App', 'emotion'),
        nav.Item('Visualization', 'polynomial'),
        nav.Item('Collections', 'get_all_databases'),
        nav.Item('Personnel', 'get_all_personnel')  #navigation_buttons
    ])


@app.route('/visualization/')
def colur():
    return simple.polynomial()


@app.route('/')
@app.route('/index/')
def index():
    return render_template("index.html")
コード例 #13
0
ファイル: bos.py プロジェクト: breedy231/Bostonography
app = Flask(__name__)
app.config.from_object(__name__)
nav = Navigation()
nav.init_app(app)

# Load default config and override config from an environment variable
app.config.update(
    dict(DATABASE=os.path.join(app.root_path, 'flaskr.db'),
         SECRET_KEY='development key',
         USERNAME='******',
         PASSWORD='******'))
app.config.from_envvar('FLASKR_SETTINGS', silent=True)

nav.Bar('top', [
    nav.Item('Alejandro', 'alejandro'),
    nav.Item('Brendan', 'brendan'),
    nav.Item('Doug', 'doug'),
])


def connect_db():
    """Connects to the specific database."""
    rv = sqlite3.connect(app.config['DATABASE'])
    rv.row_factory = sqlite3.Row
    return rv


def init_db():
    db = get_db()
    with app.open_resource('schema.sql', mode='r') as f:
        db.cursor().executescript(f.read())
コード例 #14
0
@app.route('/emotion/')
def emotion():
    return render_template("my_form.html", mood='happy', form=MessageForm())


@app.route('/emotion/', methods=['POST'])
def emotion_post():
    msg = request.form['message']
    response = unirest.post(
        "https://community-sentiment.p.mashape.com/text/",
        headers={
            "X-Mashape-Key":
            "6VWQcE5umumsh9oLsHfFlOseFGbDp1caaUKjsnj6PJRqxZKslv",
            "Content-Type": "application/x-www-form-urlencoded",
            "Accept": "application/json"
        },
        params={"txt": msg})
    return render_template("my_form.html",
                           mood=response.body['result']['sentiment'],
                           form=MessageForm())


nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Emotion App', 'emotion'),
    nav.Item('Vizualisation', 'polynomial'),
    nav.Item('Database collections', 'get_all_databases'),
    nav.Item('Database get personell', 'get_collection_methods_and_attributes')
])
コード例 #15
0
    return User.query.filter_by(id=uid).first()


login_manager.login_view = 'auth.login'

try:
    if app.config['PREFIX']:
        app.wsgi_app = PrefixMiddleware(app.wsgi_app,
                                        prefix=app.config['PREFIX'])
except KeyError:
    pass

nav.Bar('end', [
    nav.Item('Home', 'index'),
    nav.Item('Our Services', 'our_services'),
    nav.Item('Portfolio', 'portfolio'),
    nav.Item('Develop with Us', 'develop_with_us'),
    nav.Item('Log in', 'auth.login')
])

nav.Bar('buttons', [
    nav.Item('Contact Us', 'contact'),
])

#nav.Bar('login', [
#    nav.Item('Log in', 'auth.login')
#])

nav.Bar('footer', [
    nav.Item('Home', 'index'),
    nav.Item('About', 'index', args={'_anchor': 'page_1'}),
コード例 #16
0

def run(topic, number):
    tweets = get_raw_tweets(topic, number)

    tweets_strings = clean_tweets(tweets)

    plot_could(tweets_strings, topic, number)


bio_app = Flask(__name__)
nav = Navigation(bio_app)

#endpoint means the name of the function as in def
nav.Bar('top', [
    nav.Item('Home', endpoint='index'),
    nav.Item('About Me', endpoint='resume')
])


@bio_app.route('/', methods=['GET', 'POST'])
def index():
    return render_template('index.html')


@bio_app.route('/result', methods=['GET', 'POST'])
def query():
    if request.method == 'POST':
        topic = request.form['topic']
        number = request.form.get('number')
        run(topic, int(number))
        file_name = topic + '.png'
コード例 #17
0
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"


@login_manager.user_loader
def user_loader(userid):
    return user_data.get_user_by_id(userid)


#### Navigation bar setup ####
nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'home'),
    nav.Item('Showcase', 'showcase'),
    nav.Item("Chalkbags", "chalkbags"),
    nav.Item("Shop", r"shop"),
    nav.Item("About", "about")
])

#### Globals ####
data = Data()
user_data = UserData()
page_size = 5
website = Website()


@app.route('/', defaults={'page': 1})
@app.route('/page/<int:page>')
def home(page):
    return website.galery_with_tag(page)
コード例 #18
0
ファイル: __init__.py プロジェクト: schmocker/flask_template
from .config import Config
config = Config()

app = Flask(__name__)
app.config.from_object(config)
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)

    def __repr__(self):
        return '<User %r>' % self.username


from .routes import main_bp

with app.app_context():
    app.register_blueprint(main_bp)

# navigation: https://flask-navigation.readthedocs.io
nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'main_bp.home'),
    nav.Item('About', 'main_bp.about'),
])

コード例 #19
0
app.register_blueprint(admin_module)
app.register_blueprint(youtube_module)

app.register_blueprint(facebook_module)

# Flask-Selfdoc
auto = Autodoc(app)

# Flask-Navigation
nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Home', 'home'),
    nav.Item('News', 'news.all'),
    nav.Item('Youtube', 'youtube.youtube_playlists'),
    nav.Item('Media', 'media.all'),
    nav.Item('Interviews', 'interviews.all'),
    nav.Item('Reviews', 'reviews.all'),
    nav.Item('Spots', 'spots.all'),
    nav.Item('Links', 'links.all'),
])

nav.Bar('user', [
    nav.Item('My',
             'auth.profile',
             items=[
                 nav.Item('Profile', 'auth.profile'),
                 nav.Item('Password', 'auth.pwdreset'),
                 nav.Item('My Uploads', 'my_uploads'),
                 nav.Item('My Media', 'user.my_media'),
                 nav.Item('My Stories', 'my_stories')
             ]),
コード例 #20
0
ファイル: __init__.py プロジェクト: schmocker/pv-FHNW
def create_app(config):
    """
    App factory for Flask app. Setup of database, login, navbar and registering of blueprints
    :param config:
    :return: running flask app
    """
    # create pvtool
    app = Flask('pvtool')

    app.config.from_object(config)
    # database
    db.init_app(app)
    # create db
    @app.before_first_request
    def create_db():
        db.create_all()

    login_manager.init_app(app)
    login_manager.login_view = 'users.signin'
    login_manager.login_message = 'Bitte melden Sie sich an um diese Seite zu sehen.'
    login_manager.login_message_category = 'info'

    @login_manager.user_loader
    def load_user(userid):
        return User.query.filter(User.id == userid).first()

    bcrypt.init_app(app)

    @app.before_first_request
    def create_admin():
        """register an admin user via command"""
        if len(db.session.query(User).filter(
                User.user_name == 'admin').all()) > 0:
            print(db.session.query(User).filter(User._rights == 'Admin').all())
            print('There already is an admin!')
            return
        new_user = User('-', '-', '-', '-')
        new_user._rights = 'Admin'
        new_user.user_name = 'admin'
        new_user._password = '******'

        db.session.add(new_user)
        db.session.commit()
        print('created admin user')

    # allow rounding
    app.jinja_env.globals.update(round=round)

    # navigation
    nav = Navigation(app)
    nav.Bar('top', [
        nav.Item('Home', 'main.home'),
        nav.Item('Photovoltaik an der FHNW', 'main.pv_at_fhnw'),
        nav.Item('Laborübung Photovoltaik',
                 'main.test',
                 items=[
                     nav.Item('PV-Module', 'pv.pv_modules'),
                     nav.Item('Messungen', 'measurement.measurements'),
                     nav.Item('Data', 'data.data'),
                     nav.Item('Benutzer', 'users.users'),
                 ]),
    ])

    # routes
    app.register_blueprint(main_routes)
    app.register_blueprint(pv_modules_routes)
    app.register_blueprint(measurement_routes)
    app.register_blueprint(data_routes)
    app.register_blueprint(users_routes)

    app.register_error_handler(404, page_not_found)
    app.register_error_handler(500, internal_server_error)

    return app
コード例 #21
0
ファイル: __init__.py プロジェクト: wozhub/cups-accounting
class Webserver(Flask):

    def __init__(self, *args, **kwargs):
        if not args:
            kwargs.setdefault('import_name', __name__)

        Flask.__init__(self,
                       template_folder= "%s/templates" % dirname(__file__),
                       *args,
                       **kwargs)
        self.bs = Bootstrap(self)

        self.nav = Navigation()
        self.nav.init_app(self)

        self.nav.Bar('top', [
            self.nav.Item('Home', 'index'),
            self.nav.Item('Responsables', 'responsables'),
            self.nav.Item('Usuarios', 'usuarios'),
            self.nav.Item('Impresoras', 'impresoras'),
            self.nav.Item('Impresiones', 'impresiones'),
        ])

        # register the routes from the decorator
        for route, fn in registered_routes.items():
            partial_fn = partial(fn, self)
            partial_fn.__name__ = fn.__name__
            self.route(route)(partial_fn)

    def setDatabase(self, db):
        self.db = db

    @register_route("/")
    def index(self):
        return render_template(
            "base.html",
        )

    @register_route("/responsables")
    def responsables(self):
        return "r"

    @register_route("/usuarios")
    def usuarios(self):
        usuarios = self.db.session.query(Usuario).all()
        return render_template(
            "usuarios.html",
            usuarios=usuarios
        )

    @register_route("/impresoras")
    def impresoras(self):
        impresoras = self.db.session.query(Impresora).all()
        return render_template(
            "impresoras.html",
            impresoras=impresoras
        )

    @register_route("/impresiones")
    def impresiones(self):
        impresiones = self.db.session.query(Impresion).all()
        return render_template(
            "impresiones.html",
            impresiones=impresiones
        )
コード例 #22
0
    data = db.Column(db.String, unique=False, nullable=True)

    def __init__(self, email, data):
        self.email = email
        self.data = data


db.create_all()
#users = User.query.all()
app.wsgi_app = ProxyFix(app.wsgi_app)

bootstrap = Bootstrap(app)

nav = Navigation(app)
nav.Bar(
    'top',
    [nav.Item('Homepage', 'index'),
     nav.Item('Classify Data', 'classifyData')])

from flask_dance.contrib.google import make_google_blueprint, google
app.secret_key = "supersekrit"  # Replace this with your own secret!

blueprint = make_google_blueprint(
    client_id=
    "1045884176358-7ujjr3afn72o8fpatg58gvtkbf48s9o7.apps.googleusercontent.com",
    client_secret="wxpbWHrKpva3SsPbeobgzLZK",
    reprompt_consent=True,
    offline=True,
    scope=['email'])
app.register_blueprint(blueprint, url_prefix="/login")

コード例 #23
0
#!/usr/bin/python3
from flask import Flask, render_template, request, jsonify
from flask import redirect, url_for, flash, make_response
from flask import session as login_session
from flask_navigation import Navigation

app = Flask(__name__)
# TODO: [DEPLOY TASKS] Make the secret key different for deployment
app.config['SECRET_KEY'] = '00923681-4fa6-49e3-b727-9113ac78450e'

nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Home', 'home_controller'),
    nav.Item('Resume', 'resume_controller'),
    nav.Item('Work', 'work_controller'),
])


# TODO: [VIEWS] Home
@app.route('/')
def home_controller():
    return render_template('home.html')


# TODO: [VIEWS] Resume
@app.route('/resume')
def resume_controller():
    return render_template('resume.html')

コード例 #24
0
from flask_navigation import Navigation


nav = Navigation()

nav.Bar('top', [
    nav.Item('Home', 'frontend.index'),
    nav.Item('Authors', 'frontend.authors'),
    nav.Item('Books', 'frontend.books'),
    nav.Item('Useful links', 'frontend.links'),
    nav.Item('About', 'frontend.about')
])
コード例 #25
0
ファイル: views.py プロジェクト: vsibinthomas/openshift
from app import app
from flask import render_template, request
import unirest
from forms import MessageForm
import database
import simple
from flask_navigation import Navigation

nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Emotion Applic', 'emotion'),
    nav.Item('Visualise', 'polynomial'),
    nav.Item('Database Coll', 'get_all_collections')
])


@app.route('/')
#@app.route('/index/')
def index():
    return render_template("index.html")


@app.route('/emotion/')
def emotion():
    return render_template("my_form.html", mood='happy', form=MessageForm())


@app.route('/emotion/', methods=['POST'])
def emotion_post():
    msg = request.form['message']
コード例 #26
0
    return render_template("my_form.html", mood='happy', form=MessageForm())


@app.route('/emotion/', methods=['POST'])
def emotion_post():
    msg = request.form['message']
    response = unirest.post(
        "https://community-sentiment.p.mashape.com/text/",
        headers={
            "X-Mashape-Key":
            "6VWQcE5umumsh9oLsHfFlOseFGbDp1caaUKjsnj6PJRqxZKslv",
            "Content-Type": "application/x-www-form-urlencoded",
            "Accept": "application/json"
        },
        params={"txt": msg})
    return render_template("my_form.html",
                           mood=response.body['result']['sentiment'],
                           form=MessageForm())


nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Home', 'index'),
    nav.Item('Emotion App', 'emotion'),
    nav.Item('Vizualisation', 'polynomial'),
    nav.Item('Database collections', 'get_all_databases'),
    nav.Item('Database get personell', 'get_all_personnel'),
    nav.Item('Database London sample', 'get_sample_document')
])
コード例 #27
0
ファイル: mongo.py プロジェクト: regcam/choosytable
        return False

    def get_id(self):
        return str(self.email)

    @login_manager.user_loader
    def load_user(email):
        u = ct.find_one({'email': email})
        if not u:
            return False
        return User(u['email'])


nav.Bar('top', [
    nav.Item('Home', 'person'),
    nav.Item('Companies', 'company'),
    nav.Item('People', 'person'),
    nav.Item('Logout', 'logout')
])


def get_css_framework():
    return app.config.get("CSS_FRAMEWORK", "bootstrap4")


def get_link_size():
    return app.config.get("LINK_SIZE", "sm")


def get_alignment():
    return app.config.get("LINK_ALIGNMENT", "")
コード例 #28
0
from flask import Flask, render_template, request
from flask_navigation import Navigation
from sendemailitem import send_simple_message

app = Flask("AvoidTheBin")
nav = Navigation(app)

nav.Bar('top', [
    nav.Item('Home', 'home'),
    nav.Item('List It', 'listit'),
    nav.Item('Listed', 'listed')
])


@app.route("/")
def home():
    return render_template("index.html")


@app.route("/listit")
def listit():
    return render_template("listit.html")


availableitems = []


def getuniquefood():
    i = 0
    x = []
    while i < len(availableitems):
コード例 #29
0
ファイル: app.py プロジェクト: schmocker/thermodynamics
from flask import Flask
from .routes import main_routes, eos_routes, tt1_routes, page_not_found, internal_server_error, Dampfturbine_routes
from flask_navigation import Navigation

app = Flask(__name__)
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'

nav = Navigation(app)
nav.Bar('top', [
    nav.Item('Home', 'main.home'),
    nav.Item('tt1', 'tt1.tt1'),
    nav.Item('Fluid/State', 'tt1.fluid_state'),
    nav.Item('EoS', 'eos.eos', items=[
        nav.Item('Equation of State', 'eos.eos'),
        nav.Item('T-S-Diagram', 'eos.ts'),
    ]),
    nav.Item('Dampfturbine', 'Dampfturbine.main'),
])

app.register_blueprint(main_routes)
app.register_blueprint(eos_routes)
app.register_blueprint(tt1_routes)
app.register_blueprint(Dampfturbine_routes)

app.register_error_handler(404, page_not_found)
app.register_error_handler(500, internal_server_error)