From 8ef49c8bf83e2d3eec4d785b6e772533eee05a82 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Wed, 31 Aug 2022 11:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 21 +++++++++++++++++++++ templates/admin.html | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/app.py b/app.py index 6640839..eb57ba0 100644 --- a/app.py +++ b/app.py @@ -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() diff --git a/templates/admin.html b/templates/admin.html index 5b1be95..dfd2aec 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -12,5 +12,9 @@

欢迎使用py_dr管理员界面

你可以在此页面在线上传规则文件到js目录或者删除js目录的文件

+
+ + +
\ No newline at end of file -- GitLab