browser-go-api/app.py

30 lines
799 B
Python
Raw Normal View History

import os
from database import db, ma
from flask import Flask
from flask_bcrypt import Bcrypt
from flask_cors import CORS
2019-10-07 17:09:49 +00:00
from flask_socketio import SocketIO
app = Flask(__name__)
bcrypt = Bcrypt(app)
app.config['CORS_HEADERS'] = 'Content-Type'
2019-10-12 05:23:38 +00:00
# ! Environment Variable
2019-10-12 06:04:11 +00:00
# TODO export CONFIGURATION_OBJECT='configuration.config.ProductionConfig'
app.config.from_object(os.getenv('CONFIGURATION_OBJECT'))
2019-10-12 05:23:38 +00:00
# ! Environment Variable
# TODO export ALLOWED_ORIGIN= whatever the react server is
2019-10-12 06:04:11 +00:00
socketio = SocketIO(app, cors_allowed_origins=os.getenv('ALLOWED_ORIGIN'))
2019-10-12 05:23:38 +00:00
def create_app():
2019-10-07 17:19:48 +00:00
CORS(app, resources={
2019-10-12 06:04:11 +00:00
r"/api/*": {"origins": os.getenv('ALLOWED_ORIGIN')},
r"/auth/*": {"origins": os.getenv('ALLOWED_ORIGIN')},
2019-10-07 17:19:48 +00:00
})
db.init_app(app)
ma.init_app(app)
return app