from flask import Flask, render_template from flask_sockets import Sockets app = Flask(__name__) sockets = Sockets(app) @sockets.route('/echo') def echo_socket(ws): while True: message = ws.receive() ws.send(message) @app.route('/') def hello(): return render_template('hello.html') if __name__ == '__main__': app.run() <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</
![FlaskでリアルタイムWebアプリが作れるようになって素晴らしい](https://cdn-ak-scissors.b.st-hatena.com/image/square/65ef6ce6680ed38c7935983c63001ce981931bee/height=288;version=1;width=512/http%3A%2F%2Fwww.kzfmix.com%2Fimages%2Fblog%2FFlask_Sockets.png)