-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
56 lines (35 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask, jsonify, request
from flask_cors import CORS
import os
app = Flask(__name__)
CORS(app)
@app.route("/upload", methods=["POST"])
def post_upload():
response = {"success": False}
f = request.files["image"]
f.save("static/input.png")
response["success"] = True
return jsonify(response)
@app.route("/is", methods=["GET"])
def get_IS():
from mla.IS import IS
res = IS()
filename = res["filename"]
image_dir = f"static/{filename}.png"
return jsonify({"success": res["success"], "image_dir": image_dir})
@app.route("/fta", methods=["GET"])
def get_FTA():
from mla.FTA import FTA
res = FTA()
filename = res["filename"]
image_dir = f"static/{filename}.png"
return jsonify({"success": res["success"], "image_dir": image_dir})
@app.route("/tod", methods=["GET"])
def get_TOD():
from mla.TOD import TOD
res = TOD()
filename = res["filename"]
image_dir = f"static/{filename}.png"
return jsonify({"success": res["success"], "image_dir": image_dir})
if __name__ == "__main__":
app.run(debug=True, port=os.getenv("PORT", default=8000))