Compare commits
6 commits
sj-game-lo
...
dev
Author | SHA1 | Date | |
---|---|---|---|
|
8fa7cc8a85 | ||
|
586a983d61 | ||
|
a7c39d9b44 | ||
|
b0e4d2aa99 | ||
|
0bca86cf79 | ||
|
c14688f1e8 |
4 changed files with 28 additions and 10 deletions
3
Procfile
3
Procfile
|
@ -1 +1,2 @@
|
||||||
web: gunicorn app:app
|
web: gunicorn server:app
|
||||||
|
release: python manage.py db upgrade
|
|
@ -8,10 +8,13 @@ def jwt_required():
|
||||||
auth_header = request.headers.get('Authorization') or None
|
auth_header = request.headers.get('Authorization') or None
|
||||||
if auth_header:
|
if auth_header:
|
||||||
auth_token = auth_header.split(" ")[1]
|
auth_token = auth_header.split(" ")[1]
|
||||||
|
try:
|
||||||
if jwt.decode(auth_token, os.environ.get('SECRET_KEY')):
|
if jwt.decode(auth_token, os.environ.get('SECRET_KEY')):
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
abort(401)
|
abort(401)
|
||||||
|
except:
|
||||||
|
abort(401)
|
||||||
else:
|
else:
|
||||||
abort(401)
|
abort(401)
|
||||||
return authorized
|
return authorized
|
||||||
|
|
|
@ -26,7 +26,6 @@ def get_room(game_id):
|
||||||
game.player_black = user['id']
|
game.player_black = user['id']
|
||||||
db.session.add(game)
|
db.session.add(game)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
print(game.player_black)
|
|
||||||
join_game_notice(game)
|
join_game_notice(game)
|
||||||
response = {'game': game_schema.dumps(game)}
|
response = {'game': game_schema.dumps(game)}
|
||||||
if game.player_black:
|
if game.player_black:
|
||||||
|
|
17
server.py
17
server.py
|
@ -1,4 +1,5 @@
|
||||||
from app import create_app, db
|
from app import create_app, db
|
||||||
|
import os
|
||||||
|
|
||||||
# Blueprints
|
# Blueprints
|
||||||
from api.api import register_api_endpoints
|
from api.api import register_api_endpoints
|
||||||
|
@ -10,8 +11,22 @@ from websockets.socket import socketio
|
||||||
import configuration.models_mount
|
import configuration.models_mount
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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()
|
app = create_app()
|
||||||
register_api_endpoints(app)
|
register_api_endpoints(app)
|
||||||
|
app.register_blueprint(server)
|
||||||
migrate = Migrate(app, db)
|
migrate = Migrate(app, db)
|
||||||
|
# added 10/14
|
||||||
|
DATABASE_URL = os.environ['DATABASE_URL']
|
||||||
|
# conn = psycopg2.connect(DATABASE_URL, sslmode='require')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
socketio.run(app, debug=True)
|
socketio.run(app, debug=True)
|
Loading…
Reference in a new issue