Skip to content

DewaldOosthuizen/python_rest_tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python_rest_tutorial

Donate License Codacy Badge

Example project to show how to to build and design RESTful web services using Python, Flask, Docker and MongoDB.

Here is an article you can follow to create this project from the beginning: https://www.dvt.co.za/news-insights/insights/item/355-restful-web-services-using-python-flask-docker-and-mongodb

Docker and docker-compose

Inside the root project you can run

sudo docker-compose build

and then run the folowing to start the container and expose the API:

sudo docker-compose up

Once the container is running, you can access it by opening your browser and typing in localhost:5000/hello. This should display a "Hello World!" message.

There are also other endpoints to test with, and can be found in the article mentioned at the top.

Using postman

When using postman to test your rest endpoints, be sure to add content-type: application/json to your headers.

If you don't want to specify content type in the header then you can use request.get_json(force=True) inside your endpoint when fetching the data from the request to force the data to be read as JSON.

For reference have a look at #1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published