Compare commits

..

1 Commits
Dev ... master

Author SHA1 Message Date
Wang Keyi
9f09ccf4b9 表单传回数据 2023-04-28 12:06:42 +08:00
3 changed files with 50 additions and 16 deletions

19
app.py
View File

@ -1,20 +1,9 @@
from config import Config, App
from flask import Flask, render_template from flask import Flask, render_template
from blueprint.Login import bp_login
from blueprint.error import bp_error
# 创建Flask应用程序实例 config = Config()
app = Flask(__name__) app_case = App()
app.register_blueprint(bp_login, url_prefix='/login') app = app_case.createApp(config)
app.register_blueprint(bp_error)
# 配置Flask应用程序实例
app.config['SECRET_KEY'] = 'Myth wky'
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__': if __name__ == '__main__':

20
blueprint/index.py Normal file
View File

@ -0,0 +1,20 @@
# -*- coding: UTF-8 -*-
"""
@Project : FlaskProject
@File : index.py
@IDE : PyCharm
@Author : 爱写屎山的王可奕
@Email : 1933658780@qq.com
@Date : 2023/4/28 12:02
@Comment : index蓝图
"""
# -*- coding: UTF-8 -*-
from flask import Blueprint, render_template
# 创建蓝图对象
bp_index = Blueprint('bp_index', __name__)
@bp_index.route('/')
def index():
return render_template('index.html')

View File

@ -6,5 +6,30 @@
@Author : 爱写屎山的王可奕 @Author : 爱写屎山的王可奕
@Email : 1933658780@qq.com @Email : 1933658780@qq.com
@Date : 2023/4/27 15:59 @Date : 2023/4/27 15:59
@Comment : Flask的配置文件 @Comment : Flask的配置文件,用于存放各种配置
""" """
from flask import Flask
from blueprint.Login import bp_login
from blueprint.error import bp_error
from blueprint.index import bp_index
class Config:
"""
配置类存储对应的app.config
"""
SECRET_KEY = 'Myth wky'
class App:
"""
创建Flask应用程序实例
"""
@staticmethod
def createApp(config: Config) -> object:
app = Flask(__name__)
app.config.from_object(config) # 加载配置
# 创建Flask应用程序实例
app.register_blueprint(bp_index)
app.register_blueprint(bp_login, url_prefix='/login')
app.register_blueprint(bp_error)
return app