UnderCover/undercover/__init__.py

34 lines
909 B
Python
Raw Normal View History

# Copyright Sage Vaillancourt 2021
import os
2022-09-24 10:25:04 -04:00
import sys
from flask import Flask
2022-09-27 21:55:10 -04:00
from flask_minify import Minify
import undercover.routes
def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True)
2022-09-27 21:55:10 -04:00
Minify(app=app, html=True, js=True, cssless=True)
2022-09-24 10:25:04 -04:00
secret_key = os.environ.get('UNDERCOVER_SECRET_KEY')
if not secret_key:
sys.stderr.write("WARNING: UNDERCOVER_SECRET_KEY is not defined! Application may be insecure.\n")
secret_key = "dev"
app.config.from_mapping(
2022-09-24 10:25:04 -04:00
SECRET_KEY=secret_key,
# DATABASE=os.path.join(app.instance_path, 'undercover.sqlite'),
)
# if test_config is None:
# app.config.from_pyfile('config.py', silent=True)
# else:
# app.config.from_mapping(test_config)
os.makedirs(app.instance_path, exist_ok=True)
app.register_blueprint(routes.writing_blueprint)
return app