import os import prefix from flask import Flask, render_template from flask_sock import Sock app = Flask(__name__, ) sock = Sock(app) app.wsgi_app = prefix.PrefixMiddleware( app.wsgi_app, prefix=os.environ.get("URL_PREFIX", "") ) @app.route('/') def index(): return render_template('index.html') @sock.route('/echo') def echo(sock): while True: data = sock.receive() sock.send(data)