How can I POST data using the Requests and display it using Flask?

Viewed 15

I want to display text that was sent to the server using POST.

Imagine that I use requests.post(url="example.com", data="<a href="example.com">Example Text</a>") I would want to display something of this sort:

Example Text

My results haven't been successful. What's an easy way to do this? I've tried to use the OS module to write the posted data to index.html, but it doesn't write correctly, not even at all. It wipes all the data on index.html, but I'm not sure on how to fix it.

def badconnection():
  f = open("templates/index.html", "wt")
  f.write(request.json)
  f.close()
  return {"Sent Request", "Successful"}

If possible could answers have the posting process and the Flask problem?

0 Answers
Related