forked from rakibtg/Python-Chat-App
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatup.py
More file actions
25 lines (18 loc) · 662 Bytes
/
chatup.py
File metadata and controls
25 lines (18 loc) · 662 Bytes
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
from flask import Flask, render_template
from flask_socketio import SocketIO, emit
# https://flask-socketio.readthedocs.io/en/latest/
# https://github.com/socketio/socket.io-client
app = Flask(__name__)
app.config[ 'SECRET_KEY' ] = 'jsbcfsbfjefebw237u3gdbdc'
socketio = SocketIO( app )
@app.route( '/' )
def hello():
return render_template( './index.html' )
def messageRecived():
print( 'message was received!!!' )
@socketio.on( 'my event' )
def handle_my_custom_event( json ):
print( 'recived my event: ' + str( json ) )
socketio.emit( 'my response', json, callback=messageRecived )
if __name__ == '__main__':
socketio.run( app, debug = True )