__init__.py
2.7 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# coding=utf-8
#author: 4N
#createtime: 2020/12/8
#email: nheweijun@sina.com
from flasgger import swag_from
from flask import Blueprint
from app.util import BlueprintApi
from flask import send_from_directory,current_app,send_file
import os
import shutil
from . import data_download
from . import get_meta
from . import data_entry_by_meta
from . import get_data_list
from flask import after_this_request
import time
class DataManager(BlueprintApi):
bp:Blueprint = Blueprint("DataTool", __name__, url_prefix="/API/IO")
@staticmethod
@bp.route('/Download/<file>', methods=['GET'])
def table_download_file(file):
parent = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
dirpath = os.path.join(parent,"file_tmp")
# @staticmethod
# @after_this_request
# def delete(response):
# try:
# os.remove(os.path.join(dirpath,file))
# # shutil.rmtree(dirpath)
# print("删除文件成功!")
# except Exception as e:
# print(e)
# print("删除文件失败!")
# return response
return send_from_directory(dirpath, filename=file, as_attachment=True)
@staticmethod
@bp.route('/DeleteFile/<file>', methods=['GET'])
def d_file(file):
parent = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
dirpath = os.path.join(parent, "file_tmp")
result={}
try:
os.remove(os.path.join(dirpath, file))
# shutil.rmtree(dirpath)
result["message"]="删除文件成功!"
except Exception as e:
print(e)
result["message"] ="删除文件失败!"
return result
@staticmethod
@bp.route('/DataDownload', methods=['POST'])
@swag_from(data_download.Api.api_doc)
def table_download():
"""
下载数据
"""
return data_download.Api().result
@staticmethod
@bp.route('/GetMeta', methods=['POST'])
@swag_from(get_meta.Api.api_doc)
def get_meta():
"""
数据Meta
"""
return get_meta.Api().result
@staticmethod
@bp.route('/GetDataList', methods=['POST'])
@swag_from(get_data_list.Api.api_doc)
def get_data_list():
"""
本地数据list
"""
return get_data_list.Api().result
@staticmethod
@bp.route('/DataEntryByMeta', methods=['POST'])
@swag_from(data_entry_by_meta.Api.api_doc)
def data_entry_by_meta():
"""
数据入库ByMeta
"""
return data_entry_by_meta.Api().result