Esempio n. 1
0
    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)
Esempio n. 2
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():
Esempio n. 3
0
        },
        r"/listens/*": {
            "origins":
            ["http://silchesterplayers.org", "https://silchesterplayers.org"]
        },
        r"/soundcounter/*": {
            "origins":
            ["http://silchesterplayers.org", "https://silchesterplayers.org"]
        },
        r"/sp-post*": {
            "origins":
            ["http://silchesterplayers.org", "https://silchesterplayers.org"]
        },
        r"/sp-entry": {
            "origins":
            ["http://silchesterplayers.org", "https://silchesterplayers.org"]
        }
    })

db = SQLAlchemy(app)
login_manager = LoginManager()
login_manager.init_app(app)
nav = Navigation()
nav.init_app(app)

app.env_vars = env_vars

from webapp import routes

# db.create_all()
Esempio n. 4
0
                   BaseBlueprint)
from flask_caching import Cache

from flask_wtf.csrf import CsrfProtect
from flask_navigation import Navigation
from speaklater import is_lazy_string
from werkzeug.contrib.fixers import ProxyFix

APP_NAME = __name__.split('.')[0]
ROOT_DIR = abspath(join(dirname(__file__)))

log = logging.getLogger(__name__)

cache = Cache()
csrf = CsrfProtect()
nav = Navigation()


class UDataApp(Flask):
    debug_log_format = '[%(levelname)s][%(name)s:%(lineno)d] %(message)s'

    # Keep track of static dirs given as register_blueprint argument
    static_prefixes = {}

    def send_static_file(self, filename):
        '''
        Override default static handling:
        - raises 404 if not debug
        - handle static aliases
        '''
        if not self.debug:
    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')
])
Esempio n. 6
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')
])
Esempio n. 7
0
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String, unique=True, nullable=False)
    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'])
Esempio n. 8
0
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
Esempio n. 9
0
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
        )
Esempio n. 10
0
app = Flask(__name__)
app.config.update(SECRET_KEY='541')

#### Login Manager Setup ####
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()

Esempio n. 11
0
app.register_blueprint(interviews_module)
app.register_blueprint(reviews_module)
app.register_blueprint(news_module)
app.register_blueprint(stories_module)
app.register_blueprint(users_module)
app.register_blueprint(user_module)
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',
Esempio n. 12
0
except ImportStringError:
    print('Warning: secret_config.py not found')


# Add the fathom analytics ID
@app.context_processor
def inject_id():
    if 'FATHOM_ID' in app.config.keys():
        return dict(FATHOM_ID=app.config['FATHOM_ID'])

    return {}


# Register extensions with app
db = SQLAlchemy(app)
nav = Navigation(app)
login_manager = LoginManager(app)
principals = Principal(app)
register_template_utils(app)
Session(app)
#socketio = SocketIO(app, manage_session=False, path='dreamingspires/socket.io')
socketio = SocketIO(app, manage_session=False)
# Sessions are managed with flask-session
migrate = Migrate(app, db)
mail = Mail(app)
admin = Admin(app, name='Dreaming Spires Admin', template_mode='bootstrap3')

# Define the back-end file storage
try:
    default_storage = app.config['DEFAULT_STORAGE']
except KeyError:
Esempio n. 13
0
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
Esempio n. 14
0
from flask_sqlalchemy import SQLAlchemy
from flask_admin import Admin
from flask_navigation import Navigation
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
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))
Esempio n. 15
0
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'),
])

Esempio n. 16
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')

Esempio n. 17
0
from flask import Flask, request, render_template, url_for, redirect, flash, make_response
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',
Esempio n. 18
0
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']
Esempio n. 19
0
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()
Esempio n. 20
0
blueprint = make_google_blueprint(
    client_id=os.environ.get("GOOGLE_CLIENT_ID"),
    client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"),
    scope=["profile", "email"],
    offline=True,
    reprompt_consent=True)
app.register_blueprint(blueprint, url_prefix="/login")

# setup login manager
login_manager = LoginManager()
login_manager.login_view = "google.login"
login_manager.init_app(app)

mongo = PyMongo(app)
ct = mongo.db.choosytable
nav = Navigation(app)


class User(UserMixin):
    def __init__(self, email):
        self.email = email

    @staticmethod
    def is_authenticated():
        return True

    @staticmethod
    def is_active():
        return True

    @staticmethod
Esempio n. 21
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
Esempio n. 22
0
LOG = getLogger(__name__)
APP_ROOT_FOLDER = os.path.abspath(os.path.dirname(app_root.__file__))
MIGRATE_ROOT_FOLDER = os.path.abspath(
    os.path.join(APP_ROOT_FOLDER, 'migrations'))


@listens_for(Pool, 'connect', named=True)
def _on_connect(dbapi_connection, **_) -> None:
    """Set MySQL mode to TRADITIONAL on databases that don't set this automatically.

    Without this, MySQL will silently insert invalid values in the database, causing very long debugging sessions in the
    long run.
    http://www.enricozini.org/2012/tips/sa-sqlmode-traditional/
    """
    pass
    # !FIXME set this only when MYSQL database is used
    # LOG.debug('FIXME! Setting SQL Mode to TRADITIONAL.')
    # dbapi_connection.cursor().execute("SET SESSION sql_mode='TRADITIONAL'")


db = SQLAlchemy()
sentry = Sentry()
babel = Babel()
login_manager = LoginManager()
navigation = Navigation()
celery = Celery()
redis = Redis()
migrate = Migrate(directory=MIGRATE_ROOT_FOLDER)
cache = Cache()
Esempio n. 23
0
#web_app.py

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": [
Esempio n. 24
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')
])
Esempio n. 25
0
from flask_wtf import FlaskForm
from wtforms import TextField, validators
import http.client
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)
Esempio n. 26
0
    wc.to_file('static/' + topic + '.png')
    #imgg = Image.open('static/words.png')

    print(f'Here is the result of {number} tweets about #{topic}')


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():
Esempio n. 27
0
from flask import Flask, render_template
from flask_script import Manager
from flask_bootstrap import Bootstrap
from flask_moment import Moment
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, SelectField
from wtforms.validators import Required, AnyOf
from flask_navigation import Navigation
from algo import *

app = Flask(__name__)
nav = Navigation(app)
app.config['SECRET_KEY'] = 'reallyreallyreallyreallysecretkey'

manager = Manager(app)
bootstrap = Bootstrap(app)
moment = Moment(app)
#choices for length in form
choices = [('1day', '1 day'), ('1week', '5 Days'), ('4week', '10 Days'),
           ('3month', '5 months'), ('1year', '2 years'), ('4year', '4 years')]


class TickerForm(FlaskForm):
    #Validators check if the two tickers are in our list of tickers traded on nasdaq, amex, and nyse
    #Also require for every field to be filled out
    stock = StringField(u'Stock:',
                        validators=[
                            Required(),
                            AnyOf(symbols(),
                                  message=u'Stock is not a valid symbol!')
                        ])
Esempio n. 28
0
from flask_openid import OpenID
from werkzeug import secure_filename
from urllib2 import urlopen
from urllib import urlencode
from wtforms import Form, BooleanField, StringField, PasswordField, IntegerField, validators

# load config
config = Config()

# 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'),
    ]),
])
Esempio n. 29
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):
Esempio n. 30
0
from flask_navigation import Navigation
from feeds import FeedReader, Twitter
from auth_controller import Authentication
from db_controller import DatabaseController

app = Flask(__name__)

# SET KEYS
app.config['SECRET_KEY'] = Config.SECRET_KEY
gmaps = googlemaps.Client(key=Config.API_KEYS['googleMaps'])

# INITIALIZE CLASSES
auth = Authentication()
twitter = Twitter()
db = DatabaseController()
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'
             }),