#HTTPServer Issue with form and POST

1 messages · Page 1 of 1 (latest)

rain jetty
#

i am having issues with the HTTPServer
<form action="/update" method="post">
<label for="low">low:</label>
<input type="text" id="low" name="low"><br><br>
<label for="high">high:</label>
<input type="text" id="high" name="high"><br><br>
<label for="full">full:</label>
<input type="text" id="full" name="full"><br><br>
<label for="empty">empty:</label>
<input type="text" id="empty" name="empty"><br><br>
<label for="timeout">timeout:</label>
<input type="text" id="timeout" name="timeout"><br><br>
<input type="submit" value="Submit">
</form>

and

@server_service.route("/update", [POST], append_slash=True)
def update(request: Request):
    new_data = request.json()
    print(new_data)

and is always fails with invalid JSON
on
request.json()

orchid finch
#

Can you try and print the received data as a string instead of converting to json?

#

Im guessing the json method is trying to convert and failing yo do so... Knowing what you are receiving would be useful

rain jetty
#

i used the body element now and parse it myself, it looks normal

orchid finch
rain jetty
#

key1=val1&key2=val2 etc

#

i suppose this is a bug in the request.json() methode

orchid finch
rain jetty
#

it is a post

orchid finch
#

But you are getting a query string too? Weird

#

Wouldnt POST pack that in a JSON and send that to the "raw" URL?

rain jetty
#

wiat what? no no query string

#

i have no idea i followed the example

#

the form sems right, the post body seems right but calling .json() on the request results in this error

#

i am terribly sorry and gratefull for your help but i need to go now

orchid finch
#

No worries

rain jetty
#

got an appointment in half an hour

#

but just for another question, do you know a quick and easy way to store variables?

#

i need some variable that can be changed but need to persist

#

JSON.get und .dump could be a solution but it feels a bit much

#

is there a smaller way?

orchid finch