diff options
author | jaseg <code@jaseg.net> | 2019-03-29 22:09:16 +0900 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2019-03-29 22:09:16 +0900 |
commit | 23d392c2f7a744d38a369f8bc91cfd0f215f82b0 (patch) | |
tree | 876f3aeebd7f1d1f3bfd0612bba905853ca5d559 /gerboweb/gerboweb.py | |
parent | 84148e368d3804c841d566cd0a8f28263445ef97 (diff) | |
download | gerbolyze-23d392c2f7a744d38a369f8bc91cfd0f215f82b0.tar.gz gerbolyze-23d392c2f7a744d38a369f8bc91cfd0f215f82b0.tar.bz2 gerbolyze-23d392c2f7a744d38a369f8bc91cfd0f215f82b0.zip |
Working on the design
Diffstat (limited to 'gerboweb/gerboweb.py')
-rw-r--r-- | gerboweb/gerboweb.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gerboweb/gerboweb.py b/gerboweb/gerboweb.py index 17e03e2..1f8d884 100644 --- a/gerboweb/gerboweb.py +++ b/gerboweb/gerboweb.py @@ -9,7 +9,7 @@ from os import path import os import sqlite3 -from flask import Flask, url_for, redirect, session, make_response, render_template, request, send_file, abort +from flask import Flask, url_for, redirect, session, make_response, render_template, request, send_file, abort, flash from flask_wtf import FlaskForm from flask_wtf.file import FileField, FileRequired from wtforms.fields import RadioField @@ -26,7 +26,7 @@ class UploadForm(FlaskForm): class OverlayForm(UploadForm): upload_file = FileField(validators=[FileRequired()]) - side = RadioField('Side', choices=[('top', 'Top'), ('bottom', 'Bottom')]) + side = RadioField('Side', choices=[('top', 'Top'), ('bottom', 'Bottom')], default=lambda: session.get('last_download')) class ResetForm(FlaskForm): pass @@ -56,6 +56,7 @@ def require_session_id(fun): @app.route('/') @require_session_id def index(): + flash(f'Gerber file successfully uploaded.', 'success') forms = { 'gerber_form': UploadForm(), 'overlay_form': OverlayForm(), @@ -108,6 +109,7 @@ def upload(namespace): session_id=session['session_id'], side=upload_form.side.data) + flash(f'{"Gerber" if namespace == "gerber" else "Overlay"} file successfully uploaded.', 'success') return redirect(url_for('index')) @app.route('/render/preview/<side>') @@ -120,10 +122,12 @@ def render_preview(side): def render_download(side): if not side in ('top', 'bottom'): return abort(400, 'side must be either "top" or "bottom"') + + session['last_download'] = side return send_file(tempfile_path(f'render_{side}.png'), mimetype='image/png', as_attachment=True, - attachment_filename=f'{path.splitext(session["filename"])[0]}_render.png') + attachment_filename=f'{path.splitext(session["filename"])[0]}_render_{side}.png') @app.route('/output/download') def output_download(): |