diff --git a/Procfile b/Procfile index 8001d1a..c2f4020 100644 --- a/Procfile +++ b/Procfile @@ -1 +1,2 @@ -web: gunicorn app:app \ No newline at end of file +web: gunicorn server:app +release: python manage.py db upgrade \ No newline at end of file diff --git a/api/decorators.py b/api/decorators.py index 96d6865..f4a8e20 100644 --- a/api/decorators.py +++ b/api/decorators.py @@ -8,9 +8,12 @@ def jwt_required(): auth_header = request.headers.get('Authorization') or None if auth_header: auth_token = auth_header.split(" ")[1] - if jwt.decode(auth_token, os.environ.get('SECRET_KEY')): - return func(*args, **kwargs) - else: + try: + if jwt.decode(auth_token, os.environ.get('SECRET_KEY')): + return func(*args, **kwargs) + else: + abort(401) + except: abort(401) else: abort(401) diff --git a/api/games/api_games.py b/api/games/api_games.py index 492cf0d..9511398 100644 --- a/api/games/api_games.py +++ b/api/games/api_games.py @@ -26,7 +26,6 @@ def get_room(game_id): game.player_black = user['id'] db.session.add(game) db.session.commit() - print(game.player_black) join_game_notice(game) response = {'game': game_schema.dumps(game)} if game.player_black: diff --git a/server.py b/server.py index a67d0ec..5fae9d2 100644 --- a/server.py +++ b/server.py @@ -1,17 +1,32 @@ from app import create_app, db +import os # Blueprints from api.api import register_api_endpoints from auth.auth import auth # Web sockets -from websockets.socket import socketio +from websockets.socket import socketio import configuration.models_mount from flask_migrate import Migrate +from flask import Blueprint, jsonify +import psycopg2 +server = Blueprint('server', __name__, url_prefix='/') + +@server.route('/', methods=['GET']) +def api_home(): + response = {"message": "hello world"} + return jsonify(response) + +app = create_app() +register_api_endpoints(app) +app.register_blueprint(server) +migrate = Migrate(app, db) +# added 10/14 +DATABASE_URL = os.environ['DATABASE_URL'] +# conn = psycopg2.connect(DATABASE_URL, sslmode='require') + if __name__ == '__main__': - app = create_app() - register_api_endpoints(app) - migrate = Migrate(app, db) - socketio.run(app, debug=True) \ No newline at end of file + socketio.run(app, debug=True)