Add half of a server skeleton for iteration

This commit is contained in:
Tim Van Baak 2021-02-11 00:19:58 -08:00
parent 20976869e2
commit 05c907e203
1 changed files with 39 additions and 2 deletions

View File

@ -1,3 +1,40 @@
"""
Logic for serving a collection of documents through a web frontend.
"""
import argparse
import os
from flask import Flask, redirect, url_for, current_app, render_template
from redstring.parser import load
CONFIG_ENVVAR = 'REDSTRING_CONFIG'
app = Flask(__name__)
@app.route('/')
def root():
return redirect(url_for('index'))
@app.route('/index/')
def index():
with open('scratch/test.json') as f:
document = load(f)
return render_template('doc.jinja', document=document)
def main(): def main():
print("Hello, world!") parser = argparse.ArgumentParser(description="Run the redstring server.")
print(__name__) parser.add_argument("--config", help="Config file path.")
args = parser.parse_args()
config_path = args.config or os.environ.get(CONFIG_ENVVAR) or '/etc/redstring.conf'
# TODO
document_folder = args.config # TODO
app.config['root'] = document_folder
app.run(debug=True, port=5000)