|
|
|
@ -3,7 +3,8 @@ import subprocess
|
|
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
from flask import Flask, render_template, request, send_from_directory
|
|
|
|
|
from flask import (Flask, redirect, render_template, request,
|
|
|
|
|
send_from_directory, url_for)
|
|
|
|
|
from markdown import markdown
|
|
|
|
|
|
|
|
|
|
from prefix import PrefixMiddleware
|
|
|
|
@ -14,7 +15,6 @@ PORT = os.environ.get("PORT", 3000)
|
|
|
|
|
DEBUG = os.environ.get("DEBUG", True)
|
|
|
|
|
PREFIX = os.environ.get("PREFIX", "")
|
|
|
|
|
REPO = os.environ.get("REPO", "https://git.xpub.nl/kamo/thesis.git")
|
|
|
|
|
SERVER_NAME = os.environ.get("SERVER_NAME", "localhost:3000")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pull():
|
|
|
|
@ -45,16 +45,11 @@ def render():
|
|
|
|
|
return "rendered"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pull()
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
app.config["SERVER_NAME"] = SERVER_NAME
|
|
|
|
|
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=PREFIX)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pull()
|
|
|
|
|
with app.app_context():
|
|
|
|
|
render()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
|
def home():
|
|
|
|
|
return send_from_directory(app.root_path, "index.html")
|
|
|
|
@ -67,4 +62,10 @@ def update():
|
|
|
|
|
return "GET method not supported"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/render")
|
|
|
|
|
def request_render():
|
|
|
|
|
render()
|
|
|
|
|
return redirect(url_for("home"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.run(port=PORT, debug=DEBUG)
|
|
|
|
|