35 lines
893 B
Python
35 lines
893 B
Python
# Copyright Sage Vaillancourt 2021
|
|
|
|
import os
|
|
import sys
|
|
|
|
from flask import Flask
|
|
|
|
import undercover.routes
|
|
from undercover.css import optimize_css_file
|
|
|
|
|
|
def create_app(test_config=None):
|
|
optimize_css_file()
|
|
|
|
app = Flask(__name__, instance_relative_config=True)
|
|
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(
|
|
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
|