|
|
|
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 myutils.ConfigManager import myCongif
|
|
|
|
from werkzeug.utils import secure_filename
|
|
|
|
from web.common.utils import login_required
|
|
|
|
'''
|
|
|
|
页面路由
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@main.route('/')
|
|
|
|
async def index():
|
|
|
|
return await render_template('login.html')
|
|
|
|
|
|
|
|
@main.route('/login', methods=['GET', 'POST'])
|
|
|
|
async def login():
|
|
|
|
if request.method == 'POST':
|
|
|
|
form = await request.form
|
|
|
|
username = form.get('username')
|
|
|
|
password = form.get('password')
|
|
|
|
# Add your login logic here
|
|
|
|
if username == 'admin' and password == 'password':
|
|
|
|
return redirect(url_for('main.dashboard')) # Assuming you have a dashboard route
|
|
|
|
else:
|
|
|
|
return "Invalid credentials", 401
|
|
|
|
return await render_template('login.html')
|
|
|
|
|
|
|
|
@main.route('/dashboard')
|
|
|
|
async def dashboard():
|
|
|
|
return "Welcome to the dashboard!"
|
|
|
|
|
|
|
|
@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)
|