This repository has been archived on 2026-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
RequestCounter/app/__init__.py
T

55 lines
857 B
Python
Raw Normal View History

2022-03-26 08:02:25 +08:00
#!/usr/bin/env python3
# -- coding:utf-8 --
# @Author: markushammered@gmail.com
# @Development Tool: PyCharm
# @Create Time: 2022/3/25
# @File Name: __init__.py
from flask import Flask
from .main import main
2022-03-27 17:03:20 +08:00
class Config:
JSON_SORT_KEYS = False
JSON_AS_ASCII = False
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': ProductionConfig
}
2022-03-26 08:41:15 +08:00
def create_app(config_name):
2022-03-26 08:02:25 +08:00
"""创建主app"""
app = Flask(__name__)
2022-03-26 08:41:15 +08:00
app.config.from_object(config[config_name])
config[config_name].init_app(app)
2022-03-26 08:02:25 +08:00
app.register_blueprint(main)
return app
2022-03-26 09:07:54 +08:00
2022-03-26 08:41:15 +08:00
2022-04-02 18:03:25 +08:00
__all__ = [
'db',
'main',
'tests',
'utils',
'create_app'
]