25 lines
767 B
Python
Executable File
25 lines
767 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='')
|
|
command = shlex.split('/usr/bin/pandoc -f markdown+footnotes+inline_notes+auto_identifiers -t html5 --smart --email-obfuscation=references')
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return app.send_static_file('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(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, universal_newlines=True)
|
|
return proc.communicate(input=data)
|
|
|
|
if __name__ == "__main__":
|
|
app.debug = False
|
|
app.run()
|