27 lines
849 B
Python
Executable File
27 lines
849 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from flask import Flask, render_template, redirect, url_for, request
|
|
import subprocess
|
|
import shlex
|
|
|
|
app = Flask(__name__, static_url_path='')
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@app.route("/parse", methods=['GET', 'POST'])
|
|
def parse():
|
|
if request.method == 'GET':
|
|
return redirect(url_for('index'))
|
|
data = request.form['markdown']
|
|
proc = subprocess.Popen(app.config['COMMAND'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True)
|
|
return proc.communicate(input=data)
|
|
|
|
if __name__ == "__main__":
|
|
app.config['HOST'] = 'localhost'
|
|
app.config['PORT'] = 5000
|
|
app.config.from_object('mdlive.default_configuration')
|
|
app.config['COMMAND'] = shlex.split(app.config['PARSER'])
|
|
app.run(host=app.config['HOST'], port=app.config['PORT'])
|