1 Star 0 Fork 0

Nuyoah / scaning_block

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main_v3.py 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Nuyoah 提交于 2024-04-30 18:44 . feat:增加香港项目本地检测识别
from flask import Flask, request, jsonify
import test_similarity as test
# import tc_rgb_test_similarity_v1 as test
import os
import json
app = Flask(__name__)
@app.route('/upload_file', methods=['POST'])
def upload_file():
if 'file' not in request.files:
return jsonify({'error': 'No file part'})
file = request.files['file']
if file.filename == '':
return jsonify({'error': 'No selected file'})
print(file.filename)
# 保存上传的文件至服务器
file.save('uploads/' + file.filename)
# 相似值
try:
value = test.similarity_localImage('uploads/' + file.filename)
except Exception as e:
value = -2000
print(e)
for item in value:
item_dict = json.loads(item)
filename = str(item_dict["name"]) + ".txt"
# Write the "value" field to the file
with open(filename, 'a') as f:
f.write(str(item_dict['value'])+ "\n") # Write the dictionary entry as a string to the file
# 返回值
return_data = jsonify({
'code': 200,
'value': value
})
# os.remove('uploads/' + file.filename)
return return_data
# http服务器
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8887, threaded=True)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiaoshengdi/scaning_block.git
git@gitee.com:xiaoshengdi/scaning_block.git
xiaoshengdi
scaning_block
scaning_block
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891