Add pep8 formatter
This commit is contained in:
parent
528c98587e
commit
b45e3e4dad
@ -1,6 +1,5 @@
|
|||||||
from flask import Flask, request, session
|
from flask import Flask, request, session
|
||||||
from flask_socketio import SocketIO, emit, join_room
|
from flask_socketio import SocketIO, emit, join_room
|
||||||
import requests
|
|
||||||
|
|
||||||
from gencode import make_code
|
from gencode import make_code
|
||||||
from game import Game
|
from game import Game
|
||||||
@ -10,19 +9,18 @@ socketio = SocketIO(app, cors_allowed_origins="*")
|
|||||||
|
|
||||||
games = {}
|
games = {}
|
||||||
|
|
||||||
## Display
|
|
||||||
|
|
||||||
|
# Display
|
||||||
@socketio.on('new-game')
|
@socketio.on('new-game')
|
||||||
def on_newgame():
|
def on_newgame():
|
||||||
data = {}
|
|
||||||
session.room = make_code()
|
session.room = make_code()
|
||||||
session.game = Game(session.room)
|
session.game = Game(session.room)
|
||||||
games[session.room] = session.game
|
games[session.room] = session.game
|
||||||
join_room(session.room)
|
join_room(session.room)
|
||||||
emit('set-code', {'code': session.room})
|
emit('set-code', {'code': session.room})
|
||||||
|
|
||||||
## Contestant
|
|
||||||
|
|
||||||
|
# Contestant
|
||||||
@socketio.on('contestant-join')
|
@socketio.on('contestant-join')
|
||||||
def on_join_contestant(data):
|
def on_join_contestant(data):
|
||||||
sid = request.sid
|
sid = request.sid
|
||||||
@ -31,10 +29,11 @@ def on_join_contestant(data):
|
|||||||
join_room(session.room)
|
join_room(session.room)
|
||||||
session.game = games[session.room]
|
session.game = games[session.room]
|
||||||
session.game.add_contestant(sid, signature)
|
session.game.add_contestant(sid, signature)
|
||||||
emit('contestant-joined', {'sid': sid, 'signature': signature }, to=session.room)
|
emit('contestant-joined', {'sid': sid,
|
||||||
|
'signature': signature}, to=session.room)
|
||||||
|
|
||||||
## Host
|
|
||||||
|
|
||||||
|
# Host
|
||||||
@socketio.on('host-join')
|
@socketio.on('host-join')
|
||||||
def on_join_host(data):
|
def on_join_host(data):
|
||||||
sid = request.sid
|
sid = request.sid
|
||||||
@ -44,13 +43,17 @@ def on_join_host(data):
|
|||||||
session.game.add_host(sid)
|
session.game.add_host(sid)
|
||||||
emit('host-joined', {'sid': sid}, to=session.room)
|
emit('host-joined', {'sid': sid}, to=session.room)
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('host-start')
|
@socketio.on('host-start')
|
||||||
def on_host_start():
|
def on_host_start():
|
||||||
session.game.get_questions()
|
session.game.get_questions()
|
||||||
emit('categories', [c.name for c in session.game.categories[:6]], to=session.room)
|
emit('categories', [
|
||||||
|
c.name for c in session.game.categories[:6]], to=session.room)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
socketio.run(app, host='0.0.0.0', debug=True)
|
socketio.run(app, host='0.0.0.0', debug=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user