from flask import Flask
from config import config
from flask.ext.cors import CORS
import itsdangerous

flask_app = Flask(__name__)
flask_app.debug = config.debug()
flask_app.config.update(
    SQLALCHEMY_DATABASE_URI=config.database_connection_string(),
    CORS_HEADERS="Content-Type",
    CORS_RESOURCES={
        r"/api/*": {
            "origins": config.allowed_origins()
        }
    })

CORS(flask_app, supports_credentials=True)

flask_app.secret_key = config.secret_key()
flask_app.signer = itsdangerous.URLSafeTimedSerializer(flask_app.secret_key)
Пример #2
0
import os.path
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__),
                     os.path.pardir)))

from config import config as app_config
from app.db import db

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Override db connection with our global flask_app config's
config.set_main_option("sqlalchemy.url",
                       app_config.database_connection_string())

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
Пример #3
0
# blame both python and alembic.
import sys
import os.path
sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))

from config import config as app_config
from api.db import db

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Override db connection with our global flask_app config's
config.set_main_option("sqlalchemy.url",
                       app_config.database_connection_string())

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
Пример #4
0
from flask_api import FlaskAPI
from flask_cors import CORS, cross_origin
from config import config
import os
from flask import Blueprint

theme = Blueprint('api',
                  __name__,
                  url_prefix='/browsable-api',
                  template_folder='templates',
                  static_folder='static')

flask_app = FlaskAPI(__name__)
CORS(flask_app)

flask_app.config.update(
    DEBUG=True,
    SQLALCHEMY_DATABASE_URI=config.database_connection_string(),
    SQLALCHEMY_TRACK_MODIFICATIONS=False)

flask_app.register_blueprint(theme)
#print(flask_app.blueprints['flask-api'].static_folder)