from flask import Flask, request, abort import json app = Flask(__name__) import xxx @app.route("/", methods=['GET', 'POST']) def index(): if request.method != 'POST' or not request.data: return abort(400); params = json.loads(request.data.decode(encoding='utf-8')) pos = params['pos'] direction = params['dir'] if len(pos) > 10 or direction not in (0, 225, 270, 315): return abort(400); ws, pot = xxx.run(direction, pos); return { 'pos': pos, 'ws': ws, 'pot': pot, 'dir': direction, } if __name__ == "__main__": app.run(host='localhost', port='1234')