Add half of a server skeleton for iteration
This commit is contained in:
parent
20976869e2
commit
05c907e203
|
@ -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():
|
||||
print("Hello, world!")
|
||||
print(__name__)
|
||||
parser = argparse.ArgumentParser(description="Run the redstring server.")
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue