编写.bat文件
cmdtaskkill /f /im explorer.exe DEL /F /S /Q /A %LocalAppData%\IconCache.db DEL /F /S /Q /A %LocalAppData%\Microsoft\Windows\Explorer\iconcache_*.db del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db" start explorer.exe
api.py
pythonclass FileApi(MethodView):
"""
后端接口部分 RESTful API风格
"""
def __init__(self):
super(FileApi, self).__init__()
def get(self, fid):
"""
查询数据
:param fid: 文件id
:return: json
"""
try:
if not fid:
files: [File] = File.query.all()
results = [
{
'fid': file.fid,
'name': file.name,
'timestamp': file.timestamp,
'type': file.type,
'origin': file.origin,
'width': file.width,
'height': file.height,
'url': file.url
}
for file in files
]
else:
file = File.query.get(fid)
results = {
'fid': file.fid,
'name': file.name,
'timestamp': file.timestamp,
'type': file.type,
'origin': file.origin,
'width': file.width,
'height': file.height,
'url': file.url
}
return {
'status': 'success',
'message': '数据查询成功',
'results': results
}
except Exception as e:
return {
'status': 'error',
'message': '数据查询出现异常',
'info': str(e)
}
def delete(self, fid):
"""
删除操作
:param fid: 文件id
:return: json
"""
try:
file: File = File.query.get(fid)
file.fp = 1
# db.session.delete(file)
db.session.commit()
return {
'status': 'success',
'message': '数据删除成功',
}
except Exception as e:
return {
'status': 'error',
'message': '数据删除出现异常',
'info': str(e)
}
def post(self): # 添加数据