This repository has been archived on 2020-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
namensschilder/server.py
Simon Bruder ab156a68ea
Some checks reported errors
continuous-integration/drone/push Build was killed
Expose 8000
2020-02-01 12:52:49 +00:00

24 lines
870 B
Python
Executable file

#!/usr/bin/env python3
from flask import Flask, request, render_template, url_for, redirect
from subprocess import run
app = Flask(__name__)
def run_check(*args, **kwargs):
return run(*args, **kwargs, check=True)
@app.route("/")
def hello():
try:
name = request.args['name']
run_check(['node', 'print.js', name])
run_check(['inkscape', '-T', '-E', 'static/namensschild.eps', 'static/namensschild.pdf'])
run_check(['pstoedit', '-q', '-flat', '0.0001', '-dt', '-f', 'dxf: -polyaslines -mm', 'static/namensschild.eps', 'static/namensschild.dxf'])
run_check(['openscad', '-o', f'static/{name}.stl', 'namensschild.scad'])
return redirect(url_for('static', filename=f'{name}.stl'), code=302)
except KeyError:
return render_template('index.html.j2')
if __name__ == '__main__':
app.run(host='0.0.0.0')