Beispiel #1
0
def create_app(config_class=Config):
    if getattr(sys, 'frozen', False):
        template_folder = os.path.join(sys._MEIPASS, 'app/templates')
        static_folder = os.path.join(sys._MEIPASS, 'app/static')
        app = Flask(__name__,
                    template_folder=template_folder,
                    static_folder=static_folder)
    else:
        app = Flask(__name__)
    app.config.from_object(config_class)

    # from .models import Product, Table, Order, Payment

    db.init_app(app)
    migrate.init_app(app, db)
    bootstrap.init_app(app)
    global fa
    fa = FontAwesome(app)
    csrf.init_app(app)

    # register blueprints
    from Review.app.routes import blueprint
    app.register_blueprint(blueprint)

    # shell context for flask cli
    @app.shell_context_processor
    def ctx():
        return {'app': app, 'db': db}

    return app
Beispiel #2
0
def create_app():
    app = Flask(__name__,static_folder='./static')

   

    app.config.from_object(DevConfig)

    db.init_app(app)

    fa=FontAwesome(app)

    app.register_blueprint(api_bp,url_prefix='/api')
    
    app.register_blueprint(ui_bp,url_prefix='/')

    @app.shell_context_processor
    def make_shell_context():
        return {
            'app': app,
            'db': db,
            'Record': Record,

        }

    return app
Beispiel #3
0
def init_app():
    app = Flask(__name__)
    bootstrap = Bootstrap(app)
    app.config.from_object(Config)
    fa = FontAwesome(app)
    db.init_app(app)

    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(user_id):
        return Usuario.query.get(int(user_id))

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .category import category as category_blueprint
    app.register_blueprint(category_blueprint)

    from .product import product as product_blueprint
    app.register_blueprint(product_blueprint)

    return app
Beispiel #4
0
def create_app():
    """return initialized flask app"""
    fapp = Flask(__name__)
    fapp.config["DEBUG"] = True
    fapp.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    fapp.config.from_envvar('YOURAPPLICATION_SETTINGS')
    db.init_app(fapp)
    ma.init_app(fapp)
    compress.init_app(fapp)
    FontAwesome(fapp)
    fapp.register_blueprint(auth.auth)
    fapp.register_blueprint(coach.coach, url_prefix='/coaches')
    fapp.register_blueprint(tournament.tournament, url_prefix='/tournaments')
    fapp.register_blueprint(duster.duster, url_prefix='/duster')
    fapp.register_blueprint(deck.deck, url_prefix='/decks')
    fapp.register_blueprint(cracker.cracker, url_prefix='/api/cracker')


    admin = Admin(fapp, name='Management', template_mode='bootstrap3')
    # Add administrative views here
    admin.add_view(CoachView(Coach, db.session))
    admin.add_view(TournamentView(Tournament, db.session))
    # register wehook as Tournament service notifier
    Notificator("bank").register_notifier(WebHook(fapp.config['DISCORD_WEBHOOK_BANK']).send)
    Notificator("ledger").register_notifier(WebHook(fapp.config['DISCORD_WEBHOOK_LEDGER']).send)
    Notificator("achievement").register_notifier(WebHook(fapp.config['DISCORD_WEBHOOK_ACHIEVEMENTS']).send)
    Notificator("admin").register_notifier(
        WebHook(fapp.config['DISCORD_WEBHOOK_ADMIN']).send
    )
    Notificator('tournament').register_notifier(WebHook(fapp.config['DISCORD_WEBHOOK_TOURNAMENT']).send)
    BB2Service.register_agent(bb2.Agent(fapp.config['BB2_API_KEY']))
    return fapp
Beispiel #5
0
def create_app(testing=False):
    if not testing:
        if not os.path.exists('logs'):
            os.makedirs('logs')
        fileConfig(os.path.abspath(os.path.dirname(__file__)) + '/logging.cfg')
    app = Flask(__name__)
    app.config.from_object(Config)
    Bootstrap(app)
    Session(app)
    FontAwesome(app)
    app.config["TESTING"] = testing
    app.register_blueprint(BP_HOMEPAGE)
    app.register_blueprint(BP_EXPLORER, url_prefix='/explorer')
    app.register_blueprint(BP_TABOO, url_prefix='/taboo')
    app.register_blueprint(BP_TASKS, url_prefix='/tasks')
    app.register_blueprint(BP_CODENAMES, url_prefix="/codenames")
    app.register_blueprint(BP_QUESTIONS, url_prefix="/questions")
    logger = create_logger(app)
    if testing:
        logger.setLevel(logging.DEBUG)
    DB.init_app(app)
    with app.app_context():
        create_all_db()
    app.redis = Redis.from_url(app.config['REDIS_URL'])
    app.task_queue = rq.Queue('quasimodo-tasks',
                              connection=app.redis,
                              default_timeout=50000)

    @app.before_request
    # pylint: disable=unused-variable
    def log_the_request():
        if not app.config["TESTING"]:
            logger.info("\t".join([get_ip(), request.url, str(request.data)]))

    return app
Beispiel #6
0
def create_app():
    app = Flask(__name__)
    fa = FontAwesome(app)
    app.config['SECRET_KEY'] = 'ONOMATOpeja'
    app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}'
    db.init_app(app)


    from .views import views
    from .auth import auth

    app.register_blueprint(views, url_prefix='/')
    app.register_blueprint(auth, url_prefix='/')

    from .models import User, Note

    create_database(app)

    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(int(id))

    return app
Beispiel #7
0
def create_app(config_name):
    app = Flask(__name__)

    # Creating app configurations
    app.config.from_object(config_options[config_name])

    # Setting up configuration
    app.config.from_object(DevConfig)

    # Initializing Flask Extensions
    bootstrap.init_app(app)
    fa = FontAwesome(app)
    db.init_app(app)
    login_manager.init_app(app)

    # Registering the blueprint - main
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    # Registering the blueprint - auth
    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/authenticate')

    # configure UploadSet
    configure_uploads(app, photos)

    return app
Beispiel #8
0
def create_app():
    application = Flask(__name__)
    Bootstrap(application)
    FontAwesome(application)
    application.config[
        'SECRET_KEY'] = 'change this unsecure key'  #need for search page
    application.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1

    return application
Beispiel #9
0
def create_app(setting_module, **kwargs):

    # application settings
    app = Flask(__name__, instance_relative_config=True)

    app.config.from_object(setting_module)
    app.wsgi_app = ProxyFix(app.wsgi_app)

    celery = kwargs.get('celery')

    if celery:
        init_celery(celery, app)

    if app.config.get('TESTING', True):
        print(" * Running in development mode")
        app.config.from_envvar('APP_DEVELOPMENT_SETTINGS', silent=False)
    else:
        print(" * Running in production mode")
        app.config.from_envvar('APP_PRODUCTION_SETTINGS', silent=False)

    # library integrations
    Filter(app)
    csrf.init_app(app)
    bootstrap.init_app(app)
    FontAwesome(app)
    cors.init_app(app)
    avatars.init_app(app)
    mail.init_app(app)
    sql.init_app(app)
    ma.init_app(app)
    migrate.init_app(app, sql)
    adm.init_app(app, index_view=MyAdminIndexView())
    login.init_app(app)
    security.init_app(app,
                      user_datastore,
                      register_form=ExtendRegisterForm,
                      confirm_register_form=ExtendRegisterForm)

    # register blueprint
    from .user import user_view
    app.register_blueprint(user_view)

    from .auth import auth_view
    app.register_blueprint(auth_view)

    from .admin import admin_view
    app.register_blueprint(admin_view)

    from .tasks import tasks
    app.register_blueprint(tasks)

    # my extentions
    register_error_handlers(app)
    all_request._(app, db)
    create_user(app, user_datastore, db, Role)

    return app
Beispiel #10
0
def app():
    app = Flask(__name__)
    FontAwesome(app)

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

    return app
Beispiel #11
0
def create_app() -> Flask:
    app = Flask(__name__)
    FontAwesome(app)

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

    return app
def test_basics():
    app = Flask(__name__)
    FontAwesome(app)

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

    client = app.test_client()

    app.config['FONTAWESOME_TYPE'] = 'webfont/css'
    app.config['FONTAWESOME_USE_MINIFIED'] = True
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'css/fontawesome.min.css' in text
    assert 'css/solid.min.css' in text

    app.config['FONTAWESOME_TYPE'] = 'svg/js'
    app.config['FONTAWESOME_USE_MINIFIED'] = True
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'js/fontawesome.min.js' in text
    assert 'js/solid.min.js' in text

    app.config['FONTAWESOME_TYPE'] = 'webfont/css'
    app.config['FONTAWESOME_USE_MINIFIED'] = False
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'css/fontawesome.css' in text
    assert 'css/solid.css' in text

    app.config['FONTAWESOME_TYPE'] = 'svg/js'
    app.config['FONTAWESOME_USE_MINIFIED'] = False
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'js/fontawesome.js' in text
    assert 'js/solid.js' in text

    app.config['FONTAWESOME_SERVE_LOCAL'] = False
    app.config['FONTAWESOME_TYPE'] = 'webfont/css'
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'css/fontawesome.css' in text
    assert 'css/solid.css' in text

    app.config['FONTAWESOME_TYPE'] = 'svg/js'
    resp = client.get('/')
    assert resp.status_code == 200
    text = resp.data.decode('utf-8')
    assert 'js/fontawesome.js' in text
    assert 'js/solid.js' in text
Beispiel #13
0
def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)

    bootstrap = Bootstrap(app)
    fontawesom = FontAwesome(app)

    app.register_blueprint(app_bp)

    return app
Beispiel #14
0
    def run(self):
        global debug_on_window

        if debug_on_window:
            hostname = socket.gethostname()
            ip_addr = socket.gethostbyname(hostname)
        else:
            ip_addr = check_output(['hostname', '-I']).decode('ascii')

        print("FlaskServerThread:\tSTART")

        app = Flask(__name__)
        fa = FontAwesome(app)

        @app.route('/')
        def index():
            dropdown_list = get_essid_list()
            return render_template('register.html',
                                   dropdown_list=dropdown_list)

        @app.route('/connect', methods=['POST'])
        def connect():
            global owner
            global cam_name

            ssid = request.form['ssid']
            password = request.form['ssidpsk']
            owner = request.form['owner']
            cam_name = request.form['cam_name']
            print("/connect")
            print("\tssid => ", ssid)
            print("\tpassword => ", password)
            print("\towner => ", owner)
            print("\tcam_name => ", cam_name)

            update_config()
            set_new_ssid(ssid, password)
            return shutdown("Try to connect to SSID: " + ssid + "")

        @app.route('/q')
        def q():
            return shutdown()

        def shutdown(msg):
            global reboot_flag
            shutdown_hook = request.environ.get('werkzeug.server.shutdown')
            if shutdown_hook is not None:
                shutdown_hook()

            reboot_flag = True
            # return Response(msg, mimetype='text/plain')
            return render_template('message.html')

        app.run(host=ip_addr, debug=False)
Beispiel #15
0
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('config.py')

    app.jinja_env.filters["usd"] = usd
    app.jinja_env.filters["capitalize"] = capitalize

    csrf.init_app(app)

    db.app = app
    db.init_app(app)
    with app.app_context():
        make_class_dictable(db.Model)
        from . import models

    Migrate(app, db)
    Session(app)
    Bootstrap(app)
    FontAwesome(app)
    Mobility(app)
    JWTManager(app)

    def errorhandler(e):
        """Handle error"""
        if isinstance(e, CSRFError):
            return Redirects.login(True)

        if not isinstance(e, HTTPException):
            e = InternalServerError()
        return _templates.apology(e.name, e.code)

    for code in default_exceptions:
        app.errorhandler(code)(errorhandler)

    mail.init(app)
    stock.init(app)
    token.init(app)
    sms.init(app)
    geo.init(app)

    with app.app_context():
        from .views import auths, accounts, portfolios
        from .apis import markets, portfolios, tokens

    @app.after_request
    def after_request(response):
        """Ensure responses aren't cached"""
        response.headers[
            "Cache-Control"] = "no-cache, no-store, must-revalidate"
        response.headers["Expires"] = 0
        response.headers["Pragma"] = "no-cache"
        return response

    return app
def create_app():
    app = Flask(__name__, static_folder='static')

    app.config.from_object(DevConfig)

    app.register_blueprint(app_bp, url_prefix='/')

    fa = FontAwesome(app)

    db.init_app(app)

    return app
Beispiel #17
0
def create_app():
    """ Método para la creación de la app de Flask. """
    app = Flask(__name__)
    bootstrap = Bootstrap(app)
    fa = FontAwesome(app)

    app.config.from_object(Config)
    app.register_blueprint(auth)
    app.register_blueprint(ideas)
    app.register_blueprint(users)

    login_manager.init_app(app)

    db.init_app(app)
    return app
Beispiel #18
0
def createApp(config_file='config.py'):
    app = Flask(__name__)
    app.config.from_pyfile(config_file)

    user_manager = UserManager(app, db, User)

    fa = FontAwesome(app)

    app.register_blueprint(initialCode)

    app.register_blueprint(home)
    app.register_blueprint(index)

    app.register_blueprint(widget)
    app.register_blueprint(widget_no_auth)
    app.register_blueprint(get_json)
    app.register_blueprint(activate_pump)
    app.register_blueprint(get_widget_state)
    app.register_blueprint(toggle_auto_mode)

    app.register_blueprint(statistics)

    app.register_blueprint(user_view)
    app.register_blueprint(update_user)

    app.register_blueprint(settings)
    app.register_blueprint(restartView)
    app.register_blueprint(update_activation_level)
    app.register_blueprint(get_activation_level)
    app.register_blueprint(reset_water_level)

    app.register_blueprint(about)

    app.register_blueprint(createTables)
    app.register_blueprint(badReq)

    # app.register_blueprint(assertionError)

    db.init_app(app)
    socketio.init_app(app)

    # app.run(threaded=True, host="0.0.0.0", port="8080")

    return app
Beispiel #19
0
def create_app(config_name):

    app = Flask(__name__)

    # Creating the app configurations
    app.config.from_object(config_options[config_name])

    # Initializing flask extensions
    bootstrap.init_app(app)
    db.init_app(app)
    fa = FontAwesome(app)

    # Registering the blueprint
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)
    
       # setting config
    # from .requests import configure_request
    # configure_request(app)

    return app
Beispiel #20
0
def init_app():
    app = Flask(__name__)
    bootstrap = Bootstrap(app)
    fa = FontAwesome(app)
    app.config.from_object(Config)
    db.init_app(app)

    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(user_id):
        return Usuario.query.get(int(user_id))

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .mails import mails as mails_blueprint
    app.register_blueprint(mails_blueprint)

    return app
Beispiel #21
0
def create_app():
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_pyfile("config.py")

    Bootstrap(app)
    FontAwesome(app)
    JWTManager(app)

    from .home import homes as home_blueprint
    from .auth import auths as auth_blueprint

    from .web import web_client as web_blueprint

    app.register_blueprint(home_blueprint)
    app.register_blueprint(auth_blueprint)
    app.register_blueprint(web_blueprint)

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template("error.html", title="Error")

    return app
Beispiel #22
0
from flask import Flask
from flask_bootstrap import Bootstrap
from flask_fontawesome import FontAwesome
from config import config_options
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_mail import Mail
from flask_uploads import UploadSet, configure_uploads, IMAGES

login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'

db = SQLAlchemy()
fa = FontAwesome()
bootstrap = Bootstrap()
photos = UploadSet('photos', IMAGES)
mail = Mail()


def create_app(config_name):

    app = Flask(__name__)

    #create app configurations
    from flask_bootstrap import Bootstrap
    app.config.from_object(config_options[config_name])
    config_options[config_name].init_app(app)

    # Initializing flask extensions
    bootstrap.init_app(app)
Beispiel #23
0
from flask_apscheduler import APScheduler

from flask_bootstrap import Bootstrap

from flask_caching import Cache

from flask_fontawesome import FontAwesome

from . import routes
from .middleware import PrefixMiddleware

app = Flask(__name__)
with app.app_context():
    bootstrap = Bootstrap(app)
    fa = FontAwesome(app)
    app.config.from_object(Config)
    cache = Cache(app)
    app.cache = cache
    scheduler = APScheduler()
    scheduler.init_app(app)
    scheduler.start()

    app.register_blueprint(routes.app)

    if app.config.get("PROXY_PREFIX"):
        app.wsgi_app = PrefixMiddleware(
            app.wsgi_app, prefix=app.config.get("PROXY_PREFIX").rstrip("/"))

    if app.config.get("USER_AUTOCOMPLETE").lower() == "true":
        # Cache user list
import sys

from flask import Flask, render_template, request, jsonify, redirect, url_for
from flask_fontawesome import FontAwesome

from auto import images, containers
from interface.interface_images import IMAGES_APP
from interface.interface_containers import CONTAINERS_APP

# Silence Flask development server warning
sys.modules['flask.cli'].show_server_banner = lambda *x: None

APP = Flask(__name__)
APP.register_blueprint(IMAGES_APP)
APP.register_blueprint(CONTAINERS_APP)
FA = FontAwesome(APP)


@APP.route('/')
def home():
    """ Homepage of web interface """
    image_list, container_list = get_lists()
    return render_template('index.html',
                           images=image_list,
                           containers=container_list)


@APP.route('/login', methods=['POST'])
def login():
    """ Login to Docker """
    username = request.form['username']
Beispiel #25
0
def create_app(test_config=None):
    """create and configure the app"""
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(Config)
    from .database import db
    db.init_app(app)
    from .models.source import Source
    from .models.target import Target
    from .models.intent import Intent
    from .models.label import Label
    migrate = Migrate(app, db)
    fa = FontAwesome(app)

    # ======== Routing ============================= #
    # -------- Home -------------------------------- #
    @app.route('/', methods=['GET'])
    def index():
        data = get_stats()
        return render_template('layouts/index.html', data=data.json)

    # -------- Samples -------------------------------- #
    @app.route('/samples', methods=['GET'])
    def samples():
        return render_template('layouts/sample_list.html')

    # -------- Sample -------------------------------- #
    @app.route('/samples/<int:sample_id>', methods=['GET'])
    def sample(sample_id):
        data = get_sample(sample_id)
        return render_template('layouts/sample.html', data=data.json)

    # -------- Annotate -------------------------------- #
    @app.route('/annotate/<preference>', methods=['GET'])
    def annotate_str(preference):
        if not preference or preference.lower() == 'new':
            target = Target.query.filter(Target.tokens == None).first()

        elif preference.lower() == "uncompleted":
            target = Target.query.filter(Target.is_completed == False,
                                         Target.tokens != None).first()

        if target:
            data = get_sample(target.source.id)
            if data:
                return render_template('layouts/annotate.html', data=data.json)

        return redirect("/", code=302)

    @app.route('/annotate/<int:sample_id>', methods=['GET'])
    def annotate_int(sample_id):
        data = get_sample(sample_id)
        return render_template('layouts/annotate.html', data=data.json)

    # ======== REST API ============================= #
    # -------- Stats -------------------------------- #
    @app.route('/api/stats', methods=['GET'])
    def get_stats():
        target_samples = len(Target.query.all())
        remaining_target_samples = len(
            Target.query.filter(Target.is_completed == False).all())
        uncompleted_target_samples = len(
            Target.query.filter(Target.is_completed == False,
                                Target.tokens != None).all())

        return jsonify(
            total=target_samples,
            remaining=remaining_target_samples,
            uncompleted=uncompleted_target_samples,
        )

    # -------- Samples -------------------------------- #
    @app.route('/api/samples', methods=['GET'])
    def get_samples():
        source_samples = Source.query.all()
        if not source_samples:
            abort(404)

        target_samples = Target.query.all()
        if not target_samples:
            abort(404)

        return jsonify(samples=[{
            "id": source_sample.id,
            "source": source_sample.serialize(),
            "target": target_sample.serialize()
        }
                                for source_sample, target_sample in zip(
                                    source_samples, target_samples)])

    # -------- Samples -------------------------------- #
    @app.route('/api/samples/<int:sample_id>', methods=['GET', 'POST'])
    def get_sample(sample_id):
        if request.method == "GET":
            source_sample = Source.query.get(sample_id)
            if not source_sample:
                abort(404)

            target_sample = Target.query.get(sample_id)
            if not target_sample:
                abort(404)

            return jsonify({
                "id": sample_id,
                "source": source_sample.serialize(),
                "target": target_sample.serialize(),
            })
        elif request.method == 'POST':

            is_completed = request.json['sample_is_completed']
            if is_completed:
                target_sample = Target.query.get(sample_id)
                target_sample.is_completed = request.json[
                    'sample_is_completed']
            else:
                target_sample = Target.query.get(sample_id)
                target_sample.tokens = request.json['sample_tokens']
                target_sample.labels = request.json['sample_labels']
                target_sample.is_completed = request.json[
                    'sample_is_completed']

            db.session.commit()
            return json.dumps({'success': True}), 200, {
                'ContentType': 'application/json'
            }

    # -------- Translate -------------------------------- #
    @app.route('/api/translate', methods=['POST'])
    def translate():
        source_text = request.json['source_text']
        translation = google.get_translation(source_text)
        return jsonify(translation=translation.lower(), )

    # -------- Slot Tags ---------------------#
    @app.route('/api/tags', methods=['GET'])
    def tags():
        labels = db.session.query(Label.label).all()

        return jsonify(labels=labels, )

    return app
Beispiel #26
0
from flask_bootstrap import Bootstrap
from flask_uploads import UploadSet,configure_uploads,IMAGES
from flask_mail import Mail
from .config import DevConfig, ProdConfig
from os import environ
from flask_fontawesome import FontAwesome



bootstrap = Bootstrap()
db = SQLAlchemy()
login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'auth.login'
mail = Mail()
fa = FontAwesome()

photos = UploadSet('photos',IMAGES)

app = Flask(__name__, instance_relative_config = True)

# Setting up configuration
app.config.from_object(ProdConfig)

# Initializing flask extensions
bootstrap.init_app(app)
db.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
fa.init_app(app)
Beispiel #27
0
from flask_admin import Admin
from flask_migrate import Migrate
from flask_login import LoginManager
from flask_bootstrap import Bootstrap
from flask_admin.menu import MenuLink
from flask_sqlalchemy import SQLAlchemy
from flask_fontawesome import FontAwesome
from logging.handlers import RotatingFileHandler

app = Flask(__name__) # Instantiates app as the main package for the app
app.config.from_object(Config) # Pulls in configurations for app
db = SQLAlchemy(app) # Creates db instance
migrate = Migrate(app, db, render_as_batch=True) # Creates migrate instance
bootstrap = Bootstrap(app) # Creates bootstrap instance
login = LoginManager(app) # Creates login instance
fonts = FontAwesome(app) # Creates fonts instance
login.login_view = 'auth.login' # Creates a login view that points to login route
login.login_message = ('Please log in to access this page')

from app.main import bp as main_bp
# Main Blueprint
app.register_blueprint(main_bp)

from app.errors import bp as errors_bp
# Errors Blueprint
app.register_blueprint(errors_bp)

from app.auth import bp as auth_bp
# Auth Blueprint
app.register_blueprint(auth_bp, url_prefix='/auth')
Beispiel #28
0
import os
import random
import redis

from threading import Lock
from flask import Flask, render_template, session, request, Markup, redirect, url_for, jsonify
from flask_fontawesome import FontAwesome
from flask_socketio import SocketIO, emit, join_room, leave_room, close_room, rooms, disconnect

from app import frank, penny

async_mode = None

pinochle = Flask(__name__)

FontAwesome(pinochle)
socketio = SocketIO(pinochle, async_mode=async_mode)

thread = None
thread_lock = Lock()


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


@pinochle.route('/game', methods=['GET', 'POST'])
def game_detail():
    if request.method == 'POST':
        game_name = request.form['join_game_name']
Beispiel #29
0
from flask_bootstrap import Bootstrap
from flask_fontawesome import FontAwesome
from flask import Flask

from models import db
from views import view as view_blueprint

app = Flask(__name__)
app.config.from_pyfile('config.py')

bootstrap = Bootstrap(app)
fontawesome = FontAwesome(app)

db.init_app(app)

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

app.register_blueprint(view_blueprint)

if __name__ == '__main__':
    app.run(debug=True)
Beispiel #30
0
import redis

from threading import Lock
from flask import Flask, render_template, session, request, Markup, redirect, url_for, jsonify
from flask_fontawesome import FontAwesome
from flask_socketio import SocketIO, emit, join_room, leave_room, close_room, rooms, disconnect

from app import bev
from app import cribby
from app.utils import rotate_turn, play_or_pass, card_text_from_id

async_mode = None

cribbage = Flask(__name__)

FontAwesome(cribbage)
socketio = SocketIO(cribbage, async_mode=async_mode)

thread = None
thread_lock = Lock()


@cribbage.route('/', defaults={'reason': None}, methods=['GET', 'POST'])
@cribbage.route('/<reason>', methods=['GET', 'POST'])
def index(reason):
    reason_mapping = {
        'already-exists':
        'Oops! A game with that name is already underway. ',
        'full-game':
        "Uh oh! That game has 3 players and I can't support any more than that. "
    }