Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9f09ccf4b9 |
19
app.py
19
app.py
@ -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
20
blueprint/index.py
Normal 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')
|
27
config.py
27
config.py
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user