-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
44 lines (33 loc) · 945 Bytes
/
app.py
File metadata and controls
44 lines (33 loc) · 945 Bytes
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
from flask import Flask, request, jsonify
from inference import run_inference
import json
app = Flask(__name__)
@app.route("/echo")
def echo():
if request.args.get("query") == None:
return "To fake or not to fake, that is the question"
return request.args["query"]
@app.route("/")
def help():
help = """
method endpoint params
GET echo query
POST api/fake <body>
"""
return help
@app.route("/api/fake", methods=["POST"])
def api_fake():
if request.get_data() == "":
return jsonify(error=True, error_msg="Article not provided", data=None)
result = run_inference(str(request.get_data()))
data = {
"error": False,
"error_msg": None,
"data": result,
}
return json.dumps(data)
@app.route("/test")
def test_receive_body():
return request.get_data()
if __name__ == "__main__":
app.run(debug=True, port=6969, host="0.0.0.0")