45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
|
# Copyright Sage Vaillancourt 2021
|
||
|
|
||
|
import os
|
||
|
|
||
|
from flask import (
|
||
|
Flask, redirect, url_for, render_template, send_from_directory
|
||
|
)
|
||
|
|
||
|
import subprocess
|
||
|
import time
|
||
|
|
||
|
from writing import writing_blueprint
|
||
|
from latty import generate
|
||
|
|
||
|
def create_app(test_config=None):
|
||
|
app = Flask(__name__, instance_relative_config=True)
|
||
|
app.config.from_mapping(
|
||
|
SECRET_KEY='dev',
|
||
|
DATABASE=os.path.join(app.instance_path, 'flaskr.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
|
||
|
|
||
|
@app.route('/outputs/<unique>')
|
||
|
def output(unique):
|
||
|
root_dir = os.path.dirname(os.getcwd())
|
||
|
download = root_dir + '/undercover/outputs/'
|
||
|
generate(unique)
|
||
|
return send_from_directory(download, unique + ".pdf", as_attachment=True)
|
||
|
|
||
|
app.register_blueprint(
|
||
|
writing_blueprint,
|
||
|
#url_prefix='/writing',
|
||
|
)
|
||
|
|
||
|
return app
|