WSGI doesn't support socketio

This commit is contained in:
EvilMuffinHa 2020-10-15 09:53:50 -04:00
parent 0a10b2a076
commit 124cb54b74
2 changed files with 16 additions and 9 deletions

View File

@ -6,5 +6,7 @@ WORKDIR /root/
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
WORKDIR /root/src
CMD [ "gunicorn", "-b", "0.0.0.0:25565", "src.app:app" ] CMD [ "python", "app.py" ]
# CMD [ "gunicorn", "-b", "0.0.0.0:25565","--workers", "3", "--timeout", "86400", "src.app:app" ]

View File

@ -1,16 +1,18 @@
from flask import * from flask import *
from random import randint as rint from random import randint as rint
from src.config import Config from config import Config
from src.host import HostForm from host import HostForm
from src.join import JoinForm from join import JoinForm
from src.sec import gencode, dohash, whitelist from sec import gencode, dohash, whitelist
from logging.config import dictConfig from logging.config import dictConfig
from flask_socketio import SocketIO, emit, join_room, leave_room from flask_socketio import SocketIO, emit, join_room, leave_room
import json import json
from dotenv import load_dotenv
load_dotenv()
# Loading logging preferences # Loading logging preferences
with open("src/logger.json", "r") as f: with open("logger.json", "r") as f:
dconf = json.load(f) dconf = json.load(f)
# Establishing logger # Establishing logger
@ -44,7 +46,7 @@ def host():
hash = dohash(hostcode) hash = dohash(hostcode)
resp = redirect(url_for("play", hash=hash)) resp = redirect(url_for("play", hash=hash))
resp.set_cookie("_gid", str(hostcode)) resp.set_cookie("_gid", str(hostcode))
with open("src/templates/games.json", "r") as f: with open("templates/games.json", "r") as f:
tmp = json.load(f) tmp = json.load(f)
games[hash] = tmp games[hash] = tmp
games[hash]["hostcode"] = hostcode games[hash]["hostcode"] = hostcode
@ -57,7 +59,7 @@ def host():
session.permanent = True session.permanent = True
return resp return resp
with open("src/templates/games.json", "r") as f: with open("templates/games.json", "r") as f:
tmp = json.load(f) tmp = json.load(f)
default = [tmp["tossup"], tmp["bonus"], tmp["power"], tmp["negs"]] default = [tmp["tossup"], tmp["bonus"], tmp["power"], tmp["negs"]]
return render_template('host.html', title="Host Game", version=str(version), form=form, default=default) return render_template('host.html', title="Host Game", version=str(version), form=form, default=default)
@ -136,7 +138,10 @@ def on_join(data):
if dohash(gid) == room: if dohash(gid) == room:
username = "host" username = "host"
join_room(str(room)) join_room(str(room))
msg = {"locked": games[room]["locked"], "players": games[room]["players"]} try:
msg = {"locked": games[room]["locked"], "players": games[room]["players"]}
except KeyError:
return render_template('gamenotfound.html', title="Join Game", version=str(version))
emit('player_join_event', msg, room=room) emit('player_join_event', msg, room=room)