예제 #1
0
from flask import Flask
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from flask_seeder import FlaskSeeder
from virtualassistant import config
from flask_wtf.csrf import CSRFProtect

app = Flask(__name__)
csrf = CSRFProtect(app)

app.config["SQLALCHEMY_DATABASE_URI"] = config.SQLALCHEMY_DATABASE_URI
app.config["UPLOAD_FOLDER"] = config.UPLOAD_FOLDER
app.secret_key = config.secret_key
app.config[
    "SQLALCHEMY_TRACK_MODIFICATIONS"] = config.SQLALCHEMY_TRACK_MODIFICATIONS

db = SQLAlchemy(app)
migrate = Migrate(app, db)
seeder = FlaskSeeder()
seeder.init_app(app, db)

import virtualassistant.routes
예제 #2
0
def create_app(env_name):
    """
    Create app
    """
    # app initiliazation
    app = Flask(__name__)
    # cors
    CORS(app, supports_credentials=True)
    # cors = CORS(app)
    # cors = CORS(app, resources={r"/api/*": {"origins": "http://*****:*****@app.route('/')
    def index():
        """
        example endpoint
        """
        app.logger.info('Mostrando los posts del blog')
        return 'TAT 5005'

    # @app.after_request
    # def after_request(response):
    #     # response.headers.add('Access-Control-Allow-Origin', '*')
    #     # response.headers.add('Access-Control-Allow-Headers', 'Content-Type')
    #     response.headers.add('Access-Control-Allow-Origin', 'http://localhost:8080')
    #     response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization')
    #     response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
    #     response.headers.add('Access-Control-Allow-Credentials', 'true')
    #     print("123123123213213333333333333333333333333333333333333")
    #     return response

    return app