#!/usr/bin/env python3 from flask import Flask, request, render_template, url_for, redirect from lxml import etree 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')