-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
64 lines (53 loc) · 1.51 KB
/
server.py
File metadata and controls
64 lines (53 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import socketio
import eventlet
import eventlet.wsgi
from sympy import *
import numpy as np
import random
from json import JSONEncoder
import json
from flask import Flask, render_template
sio = socketio.Server()
app = Flask(__name__)
@sio.on('connect', namespace='/chat')
def connect(sid, environ):
print("connect ", sid)
# @sio.on('clientQ', namespace='/')
# def connect(sid, environ):
# print(sid)
# print(environ)
# sio.emit('reply', generateDerivativeQuestion())
@sio.on('questions', namespace='/')
def connect(sid, environ):
# print('here')
# temp = generateDerivativeQuestion()
# print(temp)
sio.emit('reply', temp)
@sio.on('questions2', namespace='/')
def connect(sid, environ):
# print('here')
# temp1 = generateIntegralQuestion()
# print(temp1)
sio.emit('reply2', temp1)
#
@sio.on('questions3', namespace='/')
def connect(sid, environ):
# print('here')
# temp2 = generateAlgebraQuestion()
# print(temp2)
sio.emit('reply3', temp2)
# print("connect ", sid)
# print("environ ", environ);
# print environ[0]
# @sio.on('chat message', namespace='/chat')
# def message(sid, data):
# print("message ", data)
# sio.emit('reply', room=sid)
@sio.on('disconnect', namespace='/chat')
def disconnect(sid):
print('disconnect ', sid)
if __name__ == '__main__':
# wrap Flask application with engineio's middleware
app = socketio.Middleware(sio, app)
# deploy as an eventlet WSGI server
eventlet.wsgi.server(eventlet.listen(('', 8000)), app)