manage.py
1.85 KB
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
57
58
59
from flask import request, render_template
from flaskr import create_app
from flaskr.biz import user_service
from flaskr.biz.identify_service import IdentifyService
import os
app = create_app()
@app.route("/")
def hello_world():
return "Hello World!"
# return render_template("index.html")
@app.route("/yang")
def hello_world_yang():
yang = request.args.get("name")
insert_user = user_service.insert_user(yang, 986203)
print("insert_user===", insert_user.serialize)
user = user_service.get_user_by_name(yang)
print("user===", user.serialize)
return "Hello World yang!"
@app.route("/identify", methods=["POST"])
def identify():
network_img_path = request.get_json()["img_path"]
print("network_img_path===", network_img_path)
plate_number = IdentifyService(network_img_path, None).identify()
print("plate_number===", plate_number)
return plate_number if plate_number is not None else "None"
@app.route("/identifyLocal", methods=["POST"])
def identifyLocal():
local_img_path = request.get_json()["img_path"]
print("local_img_path===", local_img_path)
plate_number = IdentifyService(None, local_img_path).identify_local()
print("plate_number===", plate_number)
return plate_number if plate_number is not None else "None"
@app.route("/upload", methods=["POST"])
def upload():
file = request.files["file"] # 获取上传的文件
file.save("uploads/" + file.filename) # 保存文件到指定路径
local_img_path = "./uploads/" + file.filename
print("local_img_path===", local_img_path)
plate_number = IdentifyService(None, local_img_path).identify_local()
os.remove(local_img_path)
print("删除图片成功===", local_img_path)
print("plate_number===", plate_number)
return plate_number if plate_number is not None else "None"
if __name__ == "__main__":
app.run(port=5000)