Skip to content

Commit 84430df

Browse files
committed
wsgi
1 parent a89c49a commit 84430df

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

OCR.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
from flask import Flask, request, jsonify
55
from werkzeug.datastructures.file_storage import FileStorage
66
import uuid
7+
from gevent import pywsgi
78

89
# 创建 Flask 应用
910
app = Flask(__name__)
1011

1112
# 设置图片保存目录
12-
UPLOAD_FOLDER = os.path.dirname(os.path.abspath(__file__)) + "/img"
13+
UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "img")
1314

1415
# 设置允许上传的文件类型
1516
ALLOWED_EXTENSIONS = ("jpg", "jpeg", "png", "bmp", "tif")
@@ -98,10 +99,18 @@ def upload_image():
9899
# 返回上传成功信息
99100
return jsonify({"code": 200, "msg": "上传成功", "data": texts})
100101

102+
101103
# 释放
102104
atexit.register(wcocr.destroy)
103105

104-
if __name__ == "__main__":
106+
# if __name__ == "__main__":
107+
# wechat_ocr_init()
108+
# # 设置端口
109+
# app.run(host="0.0.0.0", port=5001)
110+
111+
if __name__ == '__main__':
105112
wechat_ocr_init()
106-
# 设置端口
107-
app.run(host="0.0.0.0", port=5001)
113+
server = pywsgi.WSGIServer(('127.0.0.1', 5000), app)
114+
server.serve_forever()
115+
server0 = pywsgi.WSGIServer(('0.0.0.0', 5000), app)
116+
server0.serve_forever()

0 commit comments

Comments
 (0)