forked from blakearchive/transcription-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
34 lines (24 loc) · 831 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask
from flask import render_template
from flask import request
from lxml import etree
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route('/blake-transcription-test')
@app.route('/blake-transcription-test', methods=['GET', 'POST'])
def index():
xml = ''
xmlInput = ''
if request.method == 'POST':
xmlInput = request.form.get('xml')
xml = transform(xmlInput)
return show_form(xml,xmlInput)
def show_form(xml=None,xmlInput=None):
return render_template('index.html', xml=xml, xmlInput=xmlInput);
def transform(xml):
xslt_xml = etree.parse(open("xslt/transcription.xsl"))
transform = etree.XSLT(xslt_xml)
tree = etree.fromstring(xml)
return etree.tostring(transform(tree), encoding='unicode')
if __name__ == "__main__":
app.run(port=8002)