Merge pull request #18 from sorrelbri/sj-configuration
sj configuration
This commit is contained in:
commit
ce0c0bf98f
4 changed files with 16 additions and 10 deletions
18
app.py
18
app.py
|
@ -3,8 +3,6 @@ from database import db, ma
|
|||
|
||||
from flask import Flask
|
||||
|
||||
from configuration.config import DevelopmentConfig
|
||||
|
||||
from flask_bcrypt import Bcrypt
|
||||
from flask_cors import CORS
|
||||
from flask_socketio import SocketIO
|
||||
|
@ -12,13 +10,19 @@ from flask_socketio import SocketIO
|
|||
app = Flask(__name__)
|
||||
bcrypt = Bcrypt(app)
|
||||
app.config['CORS_HEADERS'] = 'Content-Type'
|
||||
app.config.from_object(DevelopmentConfig)
|
||||
socketio = SocketIO(app, cors_allowed_origins="http://localhost:3000")
|
||||
# cors_allowed_origins="http://localhost:3000"
|
||||
|
||||
# ! Environment Variable
|
||||
# TODO export CONFIGURATION_OBJECT='configuration.config.ProductionConfig'
|
||||
app.config.from_object(os.getenv('CONFIGURATION_OBJECT'))
|
||||
|
||||
# ! Environment Variable
|
||||
# TODO export ALLOWED_ORIGIN= whatever the react server is
|
||||
socketio = SocketIO(app, cors_allowed_origins=os.getenv('ALLOWED_ORIGIN'))
|
||||
|
||||
def create_app():
|
||||
CORS(app, resources={
|
||||
r"/api/*": {"origins": "http://localhost:3000"},
|
||||
r"/auth/*": {"origins": "http://localhost:3000"},
|
||||
r"/api/*": {"origins": os.getenv('ALLOWED_ORIGIN')},
|
||||
r"/auth/*": {"origins": os.getenv('ALLOWED_ORIGIN')},
|
||||
})
|
||||
db.init_app(app)
|
||||
ma.init_app(app)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
# local db
|
||||
# ! Environment Variable
|
||||
DATABASE = 'postgresql://localhost/browser-go'
|
||||
|
||||
class BaseConfig:
|
||||
|
@ -30,4 +31,4 @@ class ProductionConfig(BaseConfig):
|
|||
"""Production configuration."""
|
||||
SECRET_KEY = ''
|
||||
DEBUG = False
|
||||
SQLALCHEMY_DATABASE_URI = 'postgresql:///'
|
||||
SQLALCHEMY_DATABASE_URI = 'postgresql:///'
|
||||
|
|
|
@ -10,8 +10,6 @@ from websockets.socket import socketio
|
|||
import configuration.models_mount
|
||||
from flask_migrate import Migrate
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = create_app()
|
||||
register_api_endpoints(app)
|
||||
|
|
|
@ -29,6 +29,9 @@ def handle_connection():
|
|||
# ! Game Room Messages
|
||||
|
||||
def join_room_notice(room):
|
||||
@socketio.on('connect', namespace=f'/{room}')
|
||||
def room_socket_mount():
|
||||
print(f'/{room} socket mounted')
|
||||
@socketio.on('join room', namespace=f'/{room}')
|
||||
def connect_room(message):
|
||||
print(f'connected with ${message}')
|
||||
|
|
Loading…
Reference in a new issue