Skip to content

Instantly share code, notes, and snippets.

@tinkone
Forked from rduplain/README.md
Created July 12, 2017 17:56
Show Gist options
  • Select an option

  • Save tinkone/6c0c7c1ffc5632b607da767ef0a55f13 to your computer and use it in GitHub Desktop.

Select an option

Save tinkone/6c0c7c1ffc5632b607da767ef0a55f13 to your computer and use it in GitHub Desktop.

Revisions

  1. @rduplain rduplain revised this gist Aug 30, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original 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!"
    gives "Hello, developer!".
  2. @rduplain rduplain created this gist Aug 30, 2012.
    9 changes: 9 additions & 0 deletions README.md
    Original 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!"
    17 changes: 17 additions & 0 deletions app.py
    Original 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
    1 change: 1 addition & 0 deletions development.cfg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    HELLO = 'developer'
    10 changes: 10 additions & 0 deletions manage.py
    Original 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()
    1 change: 1 addition & 0 deletions production.cfg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    HELLO = 'world'