-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathrun.py
More file actions
43 lines (31 loc) · 872 Bytes
/
run.py
File metadata and controls
43 lines (31 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# encoding: utf-8
"""
File name: run.py
Function Des: ...
~~~~~~~~~~
author: Jerry <cuteuy@gmail.com> <http://www.skyduy.com>
"""
from flask import Flask, g
from RESTfulApi.app import api_bp
from RESTfulApi.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')
if __name__ == '__main__':
create_app(debug=True).run()