Skip to content

Instantly share code, notes, and snippets.

@Collinslenjo
Forked from cedbeu/__init__.py
Created March 3, 2018 11:36
Show Gist options
  • Select an option

  • Save Collinslenjo/294afa4a6a56252b8aa8bcec998f69b3 to your computer and use it in GitHub Desktop.

Select an option

Save Collinslenjo/294afa4a6a56252b8aa8bcec998f69b3 to your computer and use it in GitHub Desktop.

Revisions

  1. @cedbeu cedbeu revised this gist May 22, 2013. No changes.
  2. @cedbeu cedbeu revised this gist May 22, 2013. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  3. @cedbeu cedbeu revised this gist May 22, 2013. 3 changed files with 32 additions and 1 deletion.
    16 changes: 16 additions & 0 deletions \webapp\__init__.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,23 @@
    #!/usr/bin/python
    # coding: utf-8
    """ Filename: __init__.py
    Purpose: This file is required to structure the web service as a
    package, to be able to define routes in multiple modules.
    This is the most basic design pattern for multiple files
    Flask apps: http://flask.pocoo.org/docs/patterns/packages/
    Requirements:
    Author: Cédric Beuzit
    """
    from flask import Flask

    app = Flask(__name__)

    # application wide global variables and config parameters must be defined here
    # (not in `run.py`) for being able to import them in the beginning of the
    # views files but we can perfectly imagine a smarter config procedure
    app.config['HELLO_WORLD'] = 'Hello Flask!'

    # The views modules that contain the application's routes are imported here
    # Importing views modules MUST BE in the end of the file to avoid problems
    # related to circular imports http://flask.pocoo.org/docs/patterns/packages
    import webapp.views
    12 changes: 11 additions & 1 deletion \webapp\views.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,17 @@
    #!/usr/bin/python
    # coding: utf-8
    """ Filename: views.py
    Purpose: This file is one of the views file that can contain the
    routes for the application
    Requirements:
    Author: Cédric Beuzit
    """
    from webapp import app

    # importing application wide parameters and global variables that have been
    # defined in __init__.py
    message = app.config['HELLO_WORLD']

    @app.route('/')
    def webapp():
    return 'Hello World'
    return message
    5 changes: 5 additions & 0 deletions run.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    #!/usr/bin/python
    # coding: utf-8
    """ Filename: run.py
    Purpose: This file runs the Flask application service
    Requirements: Flask
    Author: Cédric Beuzit
    """
    from webapp import app

    if __name__ == '__main__':
  4. @cedbeu cedbeu revised this gist May 17, 2013. No changes.
  5. @cedbeu cedbeu revised this gist May 17, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion \webapp\__init__.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    #!/usr/bin/python
    # coding: utf-8

    from flask import Flask

    app = Flask(__name__)
  6. @cedbeu cedbeu revised this gist May 17, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion \webapp\__init__.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #!/usr/bin/python
    #coding: utf-8
    # coding: utf-8

    from flask import Flask

    app = Flask(__name__)
  7. @cedbeu cedbeu revised this gist May 17, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion \webapp\__init__.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/usr/bin/python
    # coding: utf-8
    #coding: utf-8
    from flask import Flask

    app = Flask(__name__)
  8. @cedbeu cedbeu revised this gist May 17, 2013. No changes.
  9. @cedbeu cedbeu revised this gist May 17, 2013. No changes.
  10. @cedbeu cedbeu revised this gist May 17, 2013. No changes.
  11. @cedbeu cedbeu created this gist May 17, 2013.
    7 changes: 7 additions & 0 deletions \webapp\__init__.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/usr/bin/python
    # coding: utf-8
    from flask import Flask

    app = Flask(__name__)

    import webapp.views
    7 changes: 7 additions & 0 deletions \webapp\views.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    #!/usr/bin/python
    # coding: utf-8
    from webapp import app

    @app.route('/')
    def webapp():
    return 'Hello World'
    6 changes: 6 additions & 0 deletions run.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    #!/usr/bin/python
    # coding: utf-8
    from webapp import app

    if __name__ == '__main__':
    app.run(debug=True)