예제 #1
0
def _create_flask_app():
    """Initialize the flask application"""
    flask_app = Flask(__name__, instance_relative_config=False)

    # db uri = 'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost:25432/gis'
    flask_app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'postgresql://{user}:{pw}@{host}:{port}/{db}'.format(
            user=FLAGS.postgres_user,
            pw=FLAGS.postgres_pw,
            host=FLAGS.postgres_host,
            port=FLAGS.postgres_port,
            db=FLAGS.postgres_db)
    flask_app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    if flask_app.env == 'development':
        flask_app.config['SQLALCHEMY_ECHO'] = True
    else:
        flask_app.config['SQLALCHEMY_ECHO'] = False

    with flask_app.app_context():
        #_configure_standard_logging(flask_app)
        flask_app.logger.addHandler(logging.get_absl_handler())
        db.init_app(flask_app)
        flask_app.register_blueprint(api_blueprint,
                                     url_prefix=FLAGS.api_prefix)
        return flask_app
예제 #2
0
def initialize_app(flask_app):
    configure_app(flask_app)
    db.init_app(flask_app)
    api.init_app(flask_app)

    with app.app_context():
        on_app_startup()
예제 #3
0
 def register_extensions(self, app_definition: Flask) -> None:
     db.init_app(app_definition)
예제 #4
0
from flask import Flask, redirect, render_template, request, session, make_response, url_for
from flask_sqlalchemy import SQLAlchemy
from models import State, Base
from data import db
import backend

app = Flask(__name__)
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://thecellar:thecellar@localhost:3306/thecellar'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.secret_key = 'U9Xx4C8qCPdg13PR3k0byq2Bv70thfwR'
db.init_app(app)


def loc(status, dir, type):
    for elem in status:
        if elem.key == (dir + type):
            return elem.state
    return "?"


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


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

예제 #5
0
def register_extensions(app):
    db.init_app(app)
예제 #6
0
파일: __init__.py 프로젝트: dimV36/webtests
# coding=utf-8
__author__ = 'dimv36'
from flask import Flask

from auth import login_manager
from data import db, images
from models import create_entities

# Инициализация приложения
app = Flask(__name__)
app.config.from_object('config')

# Связь приложения с базой данных
db.init_app(app)
db.app = app

# Связь приложения с модулем динамической загрузки изображений
images.init_app(app)
images.app = app

# Инициализация менеджера входа
login_manager.init_app(app)

# Создание структур таблиц
db.create_all(app=app)
# Наполнение таблиц минимально необходимыми данными
create_entities()

from webtests import views, models