-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (31 loc) · 1.05 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
# encoding: utf-8
"""
@author: xyliao
@contact: [email protected]
"""
import json
import flask
import csv
from flask_cors import *
# Initialize our Flask application and the PyTorch model.
app = flask.Flask(__name__)
CORS(app, supports_credentials=True) #设置允许跨域
str='失败'
@app.route("/predict", methods=["post"])
def predict():
tableData = []
if flask.request.method == 'POST':
print('接受到post请求')
print(flask.request.values.get("request_type"))
if flask.request.values.get("request_type"):
print('接受到request参数')
with open('deploy_result.csv', 'r') as f:
reader=csv.DictReader(f)
for row in reader:
tableData.append(dict(row))
return json.dumps(tableData,sort_keys=True,indent=2,ensure_ascii=False)
return str
if __name__ == '__main__':
print("Loading PyTorch model and Flask starting server ...")
print("Please wait until server has fully started")
app.run(host='0.0.0.0', port=5002, debug=True)