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

36 lines
766 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
2022-04-07 21:53:36 +08:00
from flask_sslify import SSLify
from .main import main as main_blueprint
from .api import api as api_blueprint
2022-04-05 17:56:46 +08:00
from app.config import config
2022-03-27 17:03:20 +08:00
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)
if config[config_name].SSL_REDIRECT:
sslify = SSLify(app)
2022-03-26 08:41:15 +08:00
app.register_blueprint(main_blueprint)
app.register_blueprint(api_blueprint, url_prefix='/api')
2022-03-26 08:02:25 +08:00
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'
]