I am very new to web programming and to Flask Socket IO.
I made a fast script to host with flask like this:
from flask import Flask, render_template
from flask_socketio import SocketIO
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)
@app.route('/', methods=['GET', 'POST'])
def index():
return "hi"
@socketio.on('message')
def handle_message(message):
print('received message: ' + message)
if __name__ == '__main__':
socketio.run(app)
And here is the client side:
import requests
session = requests.session()
a = raw_input()
while a!='stop':
r = session.post('http://localhost:5000/', data={'message':a})
#print r.text
print(r.text)
a = raw_input()
If I understood well, whenever I post something with the client side, the host should print "received message: mymessage". But unfortunately it doesn't. Could you please help me ? (I just started to learn this).
Thank you