Exemple #1
0
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile("./config.cfg")
    CORS(app)
    JWTManager(app)
    initialize_db(app)
    initialize_routes(app)
    return app
Exemple #2
0
def create_app():
    app = Flask(__name__)
    app.config.from_envvar("ENV_FILE_LOCATION")
    Bcrypt(app)
    JWTManager(app)
    initialize_routes(app)
    log_routes(app)
    CORS(app, supports_credentials=True)

    db.init_app(app)

    return app
Exemple #3
0
def init_app():
    app = Flask(__name__)
    db.connect()
    app.config['SECRET_KEY'] = config.SECRET

    @app.route('/')
    def hello_world():
        return 'Comics Api'

    routes.initialize_routes(app)
    register_commands(app)
    return app
def create_app() -> Flask:
    app = Flask(__name__)

    # Load application settings from environment variable.
    # If environment variable is not set will load development settings by default.
    app_settings = os.getenv("APP_SETTINGS", "settings.DevelopmentConfig")
    env_path = Path(".env.development").absolute()

    if not app_settings:
        raise ValueError('"APP_SETTINGS" environment variable not set')

    if app_settings == "settings.TestingConfig":
        env_path = Path(".env.testing")
    elif app_settings == "settings.ProductionConfig":
        env_path = Path(".env.production")

    # Load environment variables depending on application settings (Dev/Test/Prod)
    load_dotenv(path=env_path)
    app.config.from_object(app_settings)

    # Initialize Flask-SQLAlchemy ORM
    db.init_app(app)
    db.app = app

    # Initialize Flask-Migrate
    Migrate(app, db)

    # Initialize flask_resty api
    api = Api(app, prefix="/api")
    initialize_routes(api)

    # Initialize Flask-Bcrypt
    bcrypt_.init_app(app)

    # Initialize swagger
    template = {
        "components": {
            "securitySchemes": {
                "basicAuth": {
                    "type": "http",
                    "scheme": "basic"
                },
                "bearerAuth": {
                    "type": "http",
                    "scheme": "bearer",
                    "bearerFormat": "JWT",
                },
            }
        }
    }
    Swagger(app, template=template)

    return app
Exemple #5
0
def init_app():
    app = Flask(__name__)
    CORS(app, resources={r"*": {"origins": "*"}})
    app.config['CORS_HEADERS'] = 'Content-Type'

    db.connect()
    app.config['SECRET_KEY'] = config.SECRET

    @app.route('/')
    def hello_world():
        return 'Hotels Api'

    routes.initialize_routes(app)
    register_commands(app)
    return app
Exemple #6
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('settings')
    cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
    api = Api(app)
    api.init_app(app)
    # init influxdb client
    influxdb.init_app(app)
    # init mongodb
    # mongodb.init_app(app)
    # init mysqldb
    mysqldb.init_app(app)
    # init Marshmallow
    ma.init_app(app)
    # register resources
    initialize_routes(api)
    return app
Exemple #7
0
#Initialize the flask app
app = Flask(__name__)

#Update the app config by getting the env config
config = getEnvConfig()
app.config.from_object(config)
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)

#Initialize JWT
jwt = JWTManager(app)

#Initialize rest api
restApi = Api(app)

#Initialize db app
db.init_app(app)

#Add the blueprint from routes and initalizing rest resource
from routes import routeApp, initialize_routes
app.register_blueprint(routeApp)
initialize_routes(restApi)

#Initialize CORS
CORS(app)

if __name__ == '__main__':
    app.run(host=config.FLASK_RUN_HOST,
            port=config.FLASK_RUN_PORT,
            debug=config.DEBUG)
Exemple #8
0
from flask import Flask

from routes import initialize_routes

app = Flask(__name__)

initialize_routes(app)

if __name__ == '__main__':
    app.run()
from flask import Flask
from flask_bcrypt import Bcrypt
from flask_jwt_extended import JWTManager
from flask_restful import Api
from flask_cors import CORS, cross_origin
from routes import initialize_routes
from database.db import initialize_db
from errors import errors

app = Flask(__name__)
app.config.from_envvar('ENV_FILE_LOCATION')

cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
api = Api(app, errors=errors)
bcrypt = Bcrypt(app)
jwt = JWTManager(app)

app.config['MONGODB_SETTINGS'] = {'host': 'mongodb://localhost/bace-db'}

initialize_db(app)
initialize_routes(api)

app.run()
Exemple #10
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__version__ = '1.0.0'
__license__ = 'MIT'
__author__ = 'Josh Welchez'
__email__ = '*****@*****.**'

import routes
from flask import Flask
from flask_cors import CORS
from globals import db, config

application = Flask(__name__)
CORS(application, resources={r"*": {"origins": "*"}})
application.config['CORS_HEADERS'] = 'Content-Type'
db.connect()
application.config['SECRET_KEY'] = config.SECRET


@application.route('/')
def main_route():
    return 'Words Analysis and Grouping Engine'


routes.initialize_routes(application)

if __name__ == '__main__':
    # application.run(ssl_context='adhoc')
    application.run()
Exemple #11
0
from flask import Flask
from flask_cors import CORS

import routes
import config

# inicia flask
app = Flask(__name__, static_folder='static')
app.config['UPLOAD_FOLDER'] = config.UPLOAD_FOLDER

# configura logging
logging_level = getattr(logging, config.LOG_LEVEL.upper())
logging.basicConfig(filename=config.LOG_FILE, level=config.LOG_LEVEL)

# configura CORS(
CORS(app, resources={r"/*": {"origins": "*"}})

# inclui rotas e inicializa-as
routes.initialize_routes(app)

if __name__ == '__main__':
    if os.environ['ENV'] == 'prod' or os.environ['ENV'] == 'hmg':
        context = (os.environ['CERT'], os.environ['KEY'])
        app.run(debug=True,
                host=os.environ['HOST'],
                port=os.environ['PORT'],
                ssl_context=context)
    else:
        app.run(debug=True, host=os.environ['HOST'], port=os.environ['PORT'])
    logging.getLogger('flask_cors').level = logging.DEBUG
Exemple #12
0
from flask import Flask

from configs.db import initialize_db
from configs.google_auth import initialize_auth
from flask_restful import Api
from middleware.error_handling_middleware import errors

app = Flask(__name__)
app.config.from_envvar('ENV_FILE_LOCATION')

from routes import initialize_routes

api = Api(app, errors=errors)

initialize_db(app)
oauth = initialize_auth(app)
initialize_routes(api, args={'oauth': oauth})