2021-07-23 17:30:15 -04:00
|
|
|
# Copyright Sage Vaillancourt 2021
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from flask import (
|
|
|
|
Flask, redirect, url_for, render_template, send_from_directory
|
|
|
|
)
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import time
|
|
|
|
|
2021-07-23 23:09:08 -04:00
|
|
|
import writing
|
2021-07-23 17:30:15 -04:00
|
|
|
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(
|
2021-07-23 23:09:08 -04:00
|
|
|
writing.writing_blueprint,
|
2021-07-23 17:30:15 -04:00
|
|
|
#url_prefix='/writing',
|
|
|
|
)
|
|
|
|
|
|
|
|
return app
|