12345678910111213141516171819202122232425262728 |
- from flask import Flask, request
- from flask_cors import CORS
- import json
- app = Flask(__name__)
- CORS(app)
- @app.route("/get-path", methods=["GET"])
- def get_path():
- with open("path.json", "r") as pathFile:
- path = pathFile.read()
- return path
- @app.route("/set-path", methods=["POST"])
- def set_path():
- path = request.json.get("path")
- with open("path.json", "r") as pathFile:
- pathDict = json.load(pathFile)
- pathDict[path.get("name")] = path.get("coords")
- with open("path.json", "w") as pathFile:
- json.dump(pathDict, pathFile)
- return "ok", 200
- if __name__=="__main__":
- app.run(host='0.0.0.0')
|