Use GET instead of POST for rendering the SVGs

This allows saving or editing the links to the to be rendered SVGs
This commit is contained in:
Florian Festi 2016-05-21 20:31:04 +02:00
parent 7d6e3d7e4d
commit a903a8dfcf
1 changed files with 6 additions and 10 deletions

View File

@ -77,7 +77,7 @@ class BServer:
<body> <body>
<h1>""", name, """</h1> <h1>""", name, """</h1>
<p>""", box.__doc__, """</p> <p>""", box.__doc__, """</p>
<form action="%s" method="POST" target="_blank"> <form action="%s" method="GET" target="_blank">
<table> <table>
""" % (action)] """ % (action)]
for a in box.argparser._actions: for a in box.argparser._actions:
@ -87,7 +87,7 @@ class BServer:
if a.dest == "burn": if a.dest == "burn":
result.append("</table>\n<hr>\n<table>\n") result.append("</table>\n<hr>\n<table>\n")
result.append("""</table> result.append("""</table>
<p><button>Generate</button></p> <p><button name="render" value="1">Generate</button></p>
</form> </form>
</body> </body>
</html> </html>
@ -151,16 +151,12 @@ flex cuts, holes and slots for screws and more high level functions.
start_response(status, headers) start_response(status, headers)
return self.menu() return self.menu()
if environ["REQUEST_METHOD"] == "GET": args = ["--"+arg for arg in environ['QUERY_STRING'].split("&")]
if "--render=1" not in args:
start_response(status, headers) start_response(status, headers)
return self.args2html(name, box) return self.args2html(name, box)
elif environ["REQUEST_METHOD"] == "POST": else:
try: args = [a for a in args if a != "--render=1"]
length = int(environ.get('CONTENT_LENGTH', '0'))
except ValueError:
length = 0
body = environ['wsgi.input'].read(length).decode()
args = ["--"+arg for arg in body.split("&")]
try: try:
box.parseArgs(args) box.parseArgs(args)
except (ArgumentParserError) as e: except (ArgumentParserError) as e: