diff --git a/requirements.txt b/requirements.txt index b891cce..c6e6dcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,15 @@ -bidict==0.22.1 -click==8.1.3 -colorama==0.4.6 -Flask==2.2.2 -Flask-SocketIO==5.3.2 -itsdangerous==2.1.2 -Jinja2==3.1.2 -MarkupSafe==2.1.2 -python-engineio==4.3.4 -python-socketio==5.7.2 -Werkzeug==2.2.2 +bidict==0.22.1 +click==8.1.3 +colorama==0.4.6 +dnspython==2.3.0 +eventlet==0.33.3 +Flask==2.2.2 +Flask-SocketIO==5.3.2 +greenlet==2.0.2 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.2 +python-engineio==4.3.4 +python-socketio==5.7.2 +six==1.16.0 +Werkzeug==2.2.2 diff --git a/venture/__init__.py b/venture/app.py similarity index 81% rename from venture/__init__.py rename to venture/app.py index 6bd4db7..7b290e8 100644 --- a/venture/__init__.py +++ b/venture/app.py @@ -1,41 +1,42 @@ -from flask import Flask, request -from flask_socketio import SocketIO, emit, join_room, rooms - -from venture.code import make_code -from venture.game import Game - -games = {} - -app = Flask(__name__) -app.config['SECRET_KEY'] = 'secret!' -socketio = SocketIO(app, cors_allowed_origins="*") - -if __name__ == '__main__': - socketio.run(app) - -def with_game(listener): - global games - room = rooms()[1] - game = games[room] - def inner(event, data={}): - data['game'] = game - listener(game, data) - return inner - -@socketio.on('new-game') -def on_newgame(): - data = {} - code = make_code() - - games[code] = Game(code) - join_room(code) - emit('set-code', {'code': code}) - -@socketio.on('contestant-join') -def on_join_contestant(data): - sid = request.sid - signature = data['signature'] - room = data['room'] - join_room(room) - games[room].add_contestant(sid, signature) - emit('contestant-joined', {'sid': sid, 'signature': signature }, to=room) +from flask import Flask, request +from flask_socketio import SocketIO, emit, join_room, rooms + +from gencode import make_code +from game import Game + +games = {} + +app = Flask('venture') +socketio = SocketIO(app, cors_allowed_origins="*") + +def with_game(listener): + global games + room = rooms()[1] + game = games[room] + def inner(event, data={}): + data['game'] = game + listener(game, data) + return inner + +@socketio.on('new-game') +def on_newgame(): + data = {} + code = make_code() + games[code] = Game(code) + join_room(code) + emit('set-code', {'code': code}) + +@socketio.on('contestant-join') +def on_join_contestant(data): + sid = request.sid + signature = data['signature'] + room = data['room'] + join_room(room) + games[room].add_contestant(sid, signature) + emit('contestant-joined', {'sid': sid, 'signature': signature }, to=room) + +def main(): + socketio.run(app, host='0.0.0.0', debug=True) + +if __name__ == '__main__': + main() diff --git a/venture/code.py b/venture/gencode.py similarity index 100% rename from venture/code.py rename to venture/gencode.py