diff options
| author | Mitsuo Tokumori <rtokumori@pucp.edu.pe> | 2023-10-29 07:41:04 -0500 |
|---|---|---|
| committer | Mitsuo Tokumori <rtokumori@pucp.edu.pe> | 2023-10-29 07:41:04 -0500 |
| commit | 43f9d78f8c00e13732b809519f0529ac293fd5ab (patch) | |
| tree | d9779a6d4b511dd27cfe80b3f8d0ad2e5ef5d7da /ustayml/__init__.py | |
| parent | de8b3d760a37fc54645a2588b062f85963146070 (diff) | |
Rename to ustayml (u-stayML)
Diffstat (limited to 'ustayml/__init__.py')
| -rw-r--r-- | ustayml/__init__.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ustayml/__init__.py b/ustayml/__init__.py new file mode 100644 index 0000000..1c411e7 --- /dev/null +++ b/ustayml/__init__.py @@ -0,0 +1,44 @@ +import os + +from flask import Flask + + +def create_app(test_config=None): + # Create app object. Configuration files are relative to instance folder. + app = Flask(__name__, instance_relative_config=True) + + # Config + app.config.from_mapping( + SECRET_KEY='dev', + DATABASE=os.path.join(app.instance_path, 'ustayml.sqlite'), + ) + + if test_config is None: + app.config.from_pyfile('config.py', silent=True) + else: + app.config.from_mapping(test_config) + + try: + os.makedirs(app.instance_path) + except OSError: + pass + + # Routes + @app.route('/hello') + def hello(): + return 'Hello, World!' + + # Register functions and blueprints + from . import db + db.init_app(app) + + from .views import auth + app.register_blueprint(auth.bp) + + from .views import blog + app.register_blueprint(blog.bp) + + # Extra + app.add_url_rule('/', endpoint='index') + + return app
\ No newline at end of file |
