From 24596c944ee477d6e0d23a14a58e34612f2be3a0 Mon Sep 17 00:00:00 2001 From: Peter Ludikovsky Date: Tue, 3 May 2016 17:27:30 +0200 Subject: [PATCH] Erste funktionierende Version --- mdlive.py | 24 ++++++++++++++++++++++++ static/index.html | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 mdlive.py create mode 100644 static/index.html diff --git a/mdlive.py b/mdlive.py new file mode 100755 index 0000000..dce2638 --- /dev/null +++ b/mdlive.py @@ -0,0 +1,24 @@ +#!/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') + +@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 = True + app.run() diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..5a5f163 --- /dev/null +++ b/static/index.html @@ -0,0 +1,28 @@ + + + + Live Markdown + + + + +
+ +
+
+ + +