#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019-05-18 11:17
# @Author  : minp
# @contact : king101125s@gmail.com
# @Site    : 
# @File    : run.py
# @Software: PyCharm

from flask import Flask
from stockApi.app import api_bp,api_stock
# from stockApi.models import register_database


def create_app(**config):
    """
    创建并初始化一个 Flask App
    :param
    :return
    """
    app = Flask(__name__)
    register_config(app, config)
    # register_database(app)
    register_routes(app)
    return app


def register_config(app, config):
    if config.get('debug') is True:
        app.debug = True

    # from config import default
    # app.config.from_object(default)


def register_routes(app):
    app.register_blueprint(api_bp, url_prefix='/api')
    app.register_blueprint(api_stock, url_prefix='/api2')


if __name__ == '__main__':
    create_app(debug=True).run('127.0.0.1','5005')