You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.2 KiB
92 lines
3.2 KiB
import os
|
|
from web.main import main
|
|
from quart import render_template, send_from_directory,request
|
|
from quart import session, redirect, url_for,flash
|
|
from functools import wraps
|
|
from core.Upload_file import allowed_file
|
|
from myutils.ConfigManager import myCongif
|
|
from werkzeug.utils import secure_filename
|
|
|
|
'''
|
|
页面路由
|
|
'''
|
|
|
|
def login_required(f):
|
|
@wraps(f)
|
|
async def decorated_function(*args, **kwargs):
|
|
if 'user' not in session:
|
|
return redirect(url_for('main.index',error='未登录,请重新登录'))
|
|
return await f(*args, **kwargs)
|
|
return decorated_function
|
|
|
|
@main.route('/')
|
|
async def index():
|
|
#error = request.args.get('error')
|
|
return await render_template('实时预览.html')
|
|
#return await render_template('登录.html',error=error)
|
|
#return await render_template('index_webrtc.html')
|
|
|
|
# @main.route('/', methods=['GET', 'POST'])
|
|
# async def upload_file():
|
|
# if request.method == 'POST':
|
|
# form = await request.form
|
|
# files = await request.files
|
|
# if 'file' not in files:
|
|
# flash('No file part')
|
|
# return redirect(request.url)
|
|
# file = files['file']
|
|
# if file.filename == '':
|
|
# flash('No selected file')
|
|
# return redirect(request.url)
|
|
# if file and allowed_file(file.filename):
|
|
# print("上传文件")
|
|
# filename = secure_filename(file.filename)
|
|
# file_path = os.path.join(myCongif.get_data('UPLOAD_FOLDER'), filename)
|
|
# await file.save(file_path)
|
|
# flash('File successfully uploaded')
|
|
# return redirect(url_for('main.upload_file'))
|
|
# else:
|
|
# flash('Allowed file types are zip')
|
|
# return redirect(request.url)
|
|
# return await render_template('upload.html')
|
|
|
|
@main.route('/favicon.ico')
|
|
async def favicon():
|
|
return await send_from_directory('web/main/static', 'favicon.ico')
|
|
|
|
@main.route('/<html>')
|
|
@login_required
|
|
async def get_html(html):
|
|
return await render_template(html)
|
|
|
|
|
|
'''
|
|
各种配置文件路由
|
|
'''
|
|
@main.route('/data/<file>')
|
|
async def data(file):
|
|
return await send_from_directory('web/main/static/data', file)
|
|
|
|
@main.route('/files/<path:subdir>/<file>')
|
|
async def files(subdir,file):
|
|
return await send_from_directory(os.path.join('web/main/static/files', subdir), file)
|
|
|
|
@main.route('/images/<path:subdir>/<file>')
|
|
async def images(subdir,file):
|
|
return await send_from_directory(os.path.join('web/main/static/images', subdir), file)
|
|
|
|
@main.route('/resources/<file>')
|
|
async def resources(file):
|
|
return await send_from_directory('web/main/static/resources', file)
|
|
|
|
@main.route('/resources/<path:subdir>/<file>')
|
|
async def resources_dir(subdir,file):
|
|
return await send_from_directory(os.path.join('web/main/static/resources', subdir), file)
|
|
|
|
@main.route('/resources/css/<path:subdir>/<file>')
|
|
async def resources_css_dir(subdir,file):
|
|
return await send_from_directory(os.path.join('web/main/static/resources/css', subdir), file)
|
|
|
|
@main.route('/resources/scripts/<path:subdir>/<file>')
|
|
async def resources_scripts_dir(subdir,file):
|
|
return await send_from_directory(os.path.join('web/main/static/resources/scripts', subdir), file)
|
|
|