Hello,
A coworker wrote an HTML script that contains a form for the user to submit a TMR ( a JSON object used our natural language processing lab ) to my python script so that can ultimately be stored in a database.
I am having difficulty receiving the data from his HTML form into my python server.
Here is the relevant HTML (extracted from inspecting the source code via my browser).
<form id="tmr-form" method="post">
<input id="action-input" type="text" placeholder="Put desination address here">
<textarea id="tmr-input" name="goldTmr" placeholder="Put TMR object here"></textarea>
<button id="submit-tmr" type="submit">Submit</button>
</form>
The first text field recieves the URL of my server, and the text area recieves the TMR that will be sent to my server.
I have tried the following POST() functions:
# This version crashes and reports that goldTmr is not defined
def POST(self):
form = web.input(goldTmr)
data= "%s" %(form.goldTmr)
print(data)
# This version receives a byte string and converts it into a string, but it is not a JSON
# object anymore. Somewhere in the process of transmitting the data, all of the curly
# braces, square braces, and parentheses are replaced by a set of garbled characters.
def POST(self):
print(web.data())
sdata = (web.data()).decode()
print(sdata)
I would prefer to not ask my coworker to reprogram his HTML script, but I can not find tutorials online that use match our situation.
Any help would be appreciated.
Thank you.