Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ivencentor
dr_py
提交
8ef49c8b
D
dr_py
项目概览
ivencentor
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8ef49c8b
编写于
8月 31, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增文件上传功能
上级
cf810f21
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
0 deletion
+25
-0
app.py
app.py
+21
-0
templates/admin.html
templates/admin.html
+4
-0
未找到文件。
app.py
浏览文件 @
8ef49c8b
...
...
@@ -15,6 +15,7 @@ warnings.filterwarnings('ignore')
import
os
from
flask
import
Flask
,
jsonify
,
abort
,
request
,
redirect
,
make_response
,
render_template
,
send_from_directory
,
url_for
from
werkzeug.utils
import
secure_filename
from
js.rules
import
getRuleLists
from
utils
import
error
,
parser
from
utils.web
import
*
...
...
@@ -117,6 +118,26 @@ def login_api():
else
:
return
jsonify
(
error
.
failed
(
'登录失败,用户名或密码错误'
))
@
app
.
route
(
'/upload'
,
methods
=
[
'GET'
,
'POST'
])
def
upload_file
():
cookies
=
request
.
cookies
# print(cookies)
token
=
cookies
.
get
(
'token'
,
''
)
# print(f'mytoken:{token}')
if
not
verfy_token
(
token
):
return
render_template
(
'login.html'
)
if
request
.
method
==
'POST'
:
f
=
request
.
files
[
'file'
]
# print(request.files)
filename
=
secure_filename
(
f
.
filename
)
savePath
=
f
'js/
{
filename
}
'
# print(savePath)
f
.
save
(
savePath
)
return
jsonify
(
error
.
success
(
'文件上传成功'
))
else
:
# return render_template('upload.html')
return
jsonify
(
error
.
failed
(
'文件上传失败'
))
@
app
.
route
(
'/vod'
)
def
vod
():
t0
=
time
()
...
...
templates/admin.html
浏览文件 @
8ef49c8b
...
...
@@ -12,5 +12,9 @@
<body>
<h2
class=
"title"
>
欢迎使用py_dr管理员界面
</h2>
<p>
你可以在此页面在线上传规则文件到js目录或者删除js目录的文件
</p>
<form
action =
"/upload"
method =
"POST"
enctype =
"multipart/form-data"
>
<input
type =
"file"
name =
"file"
/>
<input
type =
"submit"
value=
"提交"
/>
</form>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录