-1

I'm fairly new to Flask and Python, coming from a Node/Express and JS background. I'm currently trying to write an RESTful API in Flask, I was wondering if there was a Flask equivalent to res.send()?

I was also wondering if my front-end was using the Fetch API and expecting a JSON object, was there anything I had to do to convert my response (like putting the data in a Python dict)?

For Fetch requests using POST method, how would I access the request data on Flask if it's a JSON object?

davidism
  • 121,510
  • 29
  • 395
  • 339
albert
  • 1,158
  • 3
  • 15
  • 35

1 Answers1

1

You could simply return a string which would be encoded into http format OR you could make use of make_response method of flask for custom response with message and error codes.

Check out this short tutorial on how to write CRUD APIs in flask - https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask

pritam
  • 2,452
  • 1
  • 21
  • 31