Browse Source

Added pad downloading.

master
Gijs 7 months ago
parent
commit
e8c36e10d7
  1. 26
      app.py
  2. 3
      requirements.txt
  3. 1
      svg_to_hpgl.py

26
app.py

@ -6,7 +6,7 @@ import sys
import tempfile
import io
import requests
# from svg_to_hpgl import svgToHPGL
from svg_to_hpgl import svgToHPGL
app = Flask(__name__)
@ -157,7 +157,7 @@ def drawing(id):
ascii_input = pad_export.text
# to SVG
svg = ascii2svg(ascii_input, params['weight']);
svg = ascii2svg(ascii_input, params['weight'])
return render_template(
'drawing.html',
@ -226,10 +226,22 @@ def catalogue():
def make_svg ():
return ''
@app.route('/hpgl/')
def hpgl ():
# generate svg
svg = make_svg()
@app.route('/hpgl/<id>')
def hpgl (id):
params = {
'pad': id or 'default',
'weight': request.args.get('w') or '3',
}
params['pad-full'] = etherpad + prefix + params['pad']
# get pad content
print(' getting ' + params['pad-full'])
pad_export = requests.get(params['pad-full'] + '/export/txt')
ascii_input = pad_export.text
# to SVG
svg = ascii2svg(ascii_input, params['weight'])
# store as a temporary file
(svg_file, svg_path) = tempfile.mkstemp()
svg_file.write(svg)
@ -241,11 +253,9 @@ def hpgl ():
os.remove(svg_path)
r = Response(hpgl, mimetype='application/hpgl')
r.headers.extend({
'Content-Disposition': 'attachment; filename="cobbled-paths.hpgl"'
})
return r
if __name__ == '__main__':

3
requirements.txt

@ -1,2 +1,3 @@
Flask
pyinkscape
pyinkscape
requests

1
svg_to_hpgl.py

@ -1,5 +1,4 @@
from hpgl_multipen_output import HpglMultipenOutput
from sys import argv
def svgToHPGL (path, speed=1, penCount=8, force=2):
e = HpglMultipenOutput()

Loading…
Cancel
Save