-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathserver.py
More file actions
34 lines (26 loc) · 1.02 KB
/
server.py
File metadata and controls
34 lines (26 loc) · 1.02 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
from flask import Flask
from flask_socketio import SocketIO, send, emit
import chatBot
app = Flask(__name__)
app.config['SECRET_KEY'] = 'mysecret'
socketio = SocketIO(app)
@socketio.on('faceverify')
def handlefaceverify(payload):
print(payload['acc_no'])
response = chatBot.converse(payload['acc_no'])
print(response)
emit('message',{'message':response['data']})
@socketio.on('message')
def handleMessage(payload):
print(payload['dataset'])
response = chatBot.converse(payload['message'])
print(response)
if('map' in response):
emit('map', {"map":1,'markers':response['data']})
elif('faceverify' in response):
emit('message',{'message':response['data'],'faceverify':1})
else:
emit('message',{'message':response['data']})
if __name__ == '__main__':
#socketio.run(app) #This WILL NOT WORK. The tutorial was sucky. Use the command below
socketio.run(app, host='0.0.0.0', debug = True, port = 3110, use_reloader = True) #Open localhost:3110 to run this in your browser -.-