-
-
Save tinkone/6c0c7c1ffc5632b607da767ef0a55f13 to your computer and use it in GitHub Desktop.
Revisions
-
rduplain revised this gist
Aug 30, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object. Running: python manage.py runserver @@ -6,4 +8,4 @@ gives "Hello, world!" on http://localhost:5000/, while running: python manage.py runserver -c development.cfg gives "Hello, developer!". -
rduplain created this gist
Aug 30, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ Running: python manage.py runserver gives "Hello, world!" on http://localhost:5000/, while running: python manage.py runserver -c development.cfg gives "Hello, developer!" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ import os from flask import Flask def create_app(config=None): app = Flask(__name__) if config is None: config = os.path.join(app.root_path, 'production.cfg') app.config.from_pyfile(config) @app.route('/') def index(): return 'Hello, %(name)s!' % {'name': app.config['HELLO']} return app This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ HELLO = 'developer' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ from flask.ext.script import Manager from app import create_app manager = Manager(create_app) manager.add_option('-c', '--config', dest='config', required=False) if __name__ == '__main__': manager.run() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ HELLO = 'world'