Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
28c6d27461 |
19
app.py
19
app.py
@ -1,9 +1,20 @@
|
||||
from config import Config, App
|
||||
from flask import Flask, render_template
|
||||
from blueprint.Login import bp_login
|
||||
from blueprint.error import bp_error
|
||||
|
||||
config = Config()
|
||||
app_case = App()
|
||||
app = app_case.createApp(config)
|
||||
# 创建Flask应用程序实例
|
||||
app = Flask(__name__)
|
||||
app.register_blueprint(bp_login, url_prefix='/login')
|
||||
app.register_blueprint(bp_error)
|
||||
|
||||
|
||||
# 配置Flask应用程序实例
|
||||
app.config['SECRET_KEY'] = 'Myth wky'
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,20 +0,0 @@
|
||||
# -*- 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,30 +6,5 @@
|
||||
@Author : 爱写屎山的王可奕
|
||||
@Email : 1933658780@qq.com
|
||||
@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