add new
This commit is contained in:
parent
e6586a9831
commit
1cb45c1a9f
@ -1,10 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from myapp import admin
|
from flask.ext.mail import Mail
|
||||||
import config
|
from flask.ext.sqlalchemy import SQLAlchemy
|
||||||
|
from werkzeug.utils import import_string
|
||||||
|
|
||||||
app = Flask(__name__)
|
mail = Mail()
|
||||||
app.config.from_object(config)
|
db = SQLAlchemy()
|
||||||
app.register_blueprint(admin)
|
blueprints = [
|
||||||
|
'myapp.main:main',
|
||||||
|
'myapp.admin:admin',
|
||||||
|
]
|
||||||
|
|
||||||
from myapp import views
|
|
||||||
|
def create_app(config):
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config.from_object(config)
|
||||||
|
mail.init_app(app)
|
||||||
|
db.init_app(app)
|
||||||
|
|
||||||
|
for bp_name in blueprints:
|
||||||
|
bp = import_string(bp_name)
|
||||||
|
app.register_blueprint(bp)
|
||||||
|
return app
|
||||||
|
5
myapp/main/__init__.py
Normal file
5
myapp/main/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from flask import Blueprint
|
||||||
|
main=Blueprint('main',__name__)
|
||||||
|
from myapp.main import views
|
7
myapp/main/views.py
Normal file
7
myapp/main/views.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from myapp.main import main
|
||||||
|
|
||||||
|
@main.route('/')
|
||||||
|
def index():
|
||||||
|
return '<h>Hello world ,I am main</h>'
|
12
run.py
12
run.py
@ -1,4 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from myapp import app
|
from werkzeug.wsgi import DispatcherMiddleware
|
||||||
|
from werkzeug.serving import run_simple
|
||||||
|
from myapp import create_app
|
||||||
|
import config
|
||||||
|
|
||||||
app.run(host="0.0.0.0", debug=True)
|
release_app = create_app('config.release')
|
||||||
|
debug_app = create_app('config.debug')
|
||||||
|
|
||||||
|
app = DispatcherMiddleware(release_app, {'/test': debug_app})
|
||||||
|
|
||||||
|
run_simple("0.0.0.0", 5000, app, use_reloader=True, use_debugger=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user