fds
This commit is contained in:
parent
148a184097
commit
16fff00ea5
1 changed files with 19 additions and 17 deletions
|
@ -5,26 +5,28 @@ from datetime import datetime
|
||||||
from flask_socketio import SocketIO, emit
|
from flask_socketio import SocketIO, emit
|
||||||
from files.__main__ import app
|
from files.__main__ import app
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
|
import sys
|
||||||
|
|
||||||
sex = SocketIO(app, async_mode='gevent-websocket')
|
if "load_chat" in sys.argv:
|
||||||
|
sex = SocketIO(app, async_mode='gevent-websocket')
|
||||||
|
|
||||||
@app.get("/chat")
|
@app.get("/chat")
|
||||||
@auth_required
|
@auth_required
|
||||||
def chat( v):
|
def chat( v):
|
||||||
return render_template("chat.html", v=v)
|
return render_template("chat.html", v=v)
|
||||||
|
|
||||||
|
|
||||||
@sex.on('speak')
|
@sex.on('speak')
|
||||||
@auth_required
|
@auth_required
|
||||||
def speak(data, v):
|
def speak(data, v):
|
||||||
|
|
||||||
data={
|
data={
|
||||||
"avatar": v.profile_url,
|
"avatar": v.profile_url,
|
||||||
"username":v.username,
|
"username":v.username,
|
||||||
"text":sanitize(data[:1000].strip()),
|
"text":sanitize(data[:1000].strip()),
|
||||||
"time": time.strftime("%d %b %Y at %H:%M:%S", time.gmtime(int(time.time()))),
|
"time": time.strftime("%d %b %Y at %H:%M:%S", time.gmtime(int(time.time()))),
|
||||||
"userlink":v.url
|
"userlink":v.url
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('speak', data)
|
emit('speak', data)
|
||||||
return '', 204
|
return '', 204
|
Loading…
Add table
Add a link
Reference in a new issue