-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (35 loc) · 1.32 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, render_template, request, redirect
from waitress import serve
import controllers as ctl
import createfiles as crtf
app = Flask(__name__)
app.config['SECRET_KEY'] = 'CasaDelPiss'
app.config["TEMPLATES_AUTO_RELOAD"] = True
@app.route('/', methods=['GET'])
def index():
rootdir = ctl.getroot()
dirs = ctl.getdir()
return render_template('index.html', dirs=dirs, rootdir=rootdir)
@app.route('/setroot', methods=['POST'])
def setroot():
path = request.form['rootdir']
ctl.setroot(path)
return redirect('/')
@app.route('/setsettings', methods=['POST'])
def setsettings():
xmlTemplate = request.form.get('XMLtemplate') or None
xmlVariables = request.form.get('XMLvariables') or None
wordTemplate = request.form.get('Wordtemplate') or None
wordVariables = request.form.get('Wordvariables') or None
subdir = request.form.get('subdir') or None
localizations = request.form.getlist('localizations[]')
ctl.setsettings(subdir, xmlTemplate, xmlVariables,
wordTemplate, wordVariables, localizations)
return redirect('/')
@app.route('/createfiles', methods=['POST'])
def createfiles():
subdir = request.headers.get('subdir')
crtf.createfiles(subdir)
return redirect('/')
if __name__ == "__main__":
serve(app, host="localhost", port="9400")