mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-07 15:01:55 -04:00
Introduce config file for application
This commit is contained in:
@@ -1,12 +1,33 @@
|
||||
import os
|
||||
from flask import Flask
|
||||
from config import configs
|
||||
from flask._compat import string_types
|
||||
|
||||
|
||||
def create_app():
|
||||
def create_app(config_name):
|
||||
application = Flask(__name__)
|
||||
|
||||
# application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
||||
# application.config.from_object(configs[config_name])
|
||||
application.config['NOTIFY_API_ENVIRONMENT'] = config_name
|
||||
application.config.from_object(configs[config_name])
|
||||
init_app(application)
|
||||
|
||||
from app.main import main as main_blueprint
|
||||
application.register_blueprint(main_blueprint)
|
||||
|
||||
return application
|
||||
|
||||
|
||||
def init_app(app):
|
||||
for key, value in app.config.items():
|
||||
if key in os.environ:
|
||||
app.config[key] = convert_to_boolean(os.environ[key])
|
||||
|
||||
|
||||
def convert_to_boolean(value):
|
||||
if isinstance(value, string_types):
|
||||
if value.lower() in ['t', 'true', 'on', 'yes', '1']:
|
||||
return True
|
||||
elif value.lower() in ['f', 'false', 'off', 'no', '0']:
|
||||
return False
|
||||
|
||||
return value
|
||||
|
||||
@@ -8,11 +8,6 @@ def index():
|
||||
return 'Hello from notifications-admin'
|
||||
|
||||
|
||||
@main.route("/")
|
||||
def idx():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@main.route("/govuk")
|
||||
def govuk():
|
||||
return render_template('govuk_template.html')
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
{% assets "css_all" %}
|
||||
<style type="text/css" src="{{ ASSET_URL }}"></style>
|
||||
{% endassets %}
|
||||
</head>
|
||||
<body>
|
||||
<h1>hi</h1>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user