Posts

Showing posts from February, 2021

RESTful APIs with Python and Flask : Part 2

Image
 Hello Friends, Welcome back !!! In my last blog we saw that how we can setup a RESTful API using Python and Flask framework. We also learned how to pass request params from client to the API call and receive it at server side. Continuation on the same, today we are going to learn how to create POST API call and pass the JSON request to it. We'll use a tool call POSTMAN to hit the POST API. If you don't have it, you can install it from below link - https://www.postman.com/downloads/ Ok, let's get started. I am assuming that you have already gone through my earlier blog and have created the directory structure for this project. If not, then please go through it and create the app.py file.  https://diwakarsinhalearn.blogspot.com/2021/02/restful-apis-with-python-and-flask-part.html Step 01 : In the app.py file, please add the below code. @app.route ( "/employee" , methods =[ "POST" ]) def employee(): data = request.get_json() if data: name =

RESTful APIs with Python and Flask : Part 01

Image
Hello Friends !!!  Welcome to this blog in which we will learn how to create RESTful APIs using Python and Flask. Python is a very simple programming language with lots of rich and powerful libraries to implement your business logic. Flask is a Python web framework which provides the facility to expose the RESTful services. In this tutorial we'll use this framework to implement the APIs. PREREQUISITE - Skill set needed for this tutorial : Basic Python understanding and familiarity with RESTful services Python Setup : Python should be install. To verify if Python is install or not please run the below command on the console - $ python --version Python 2.7.10 Above will be the output when Python is install on your m/c. Flask Setup : To install Flask please run below command on the console - $ pip install Flask Successfully installed Flask-1.1.2  .............. Above will install Flask on your m/c. IDE : Pycharm can be used as the IDE. Let's get started. SIMPLE GET REQUEST Step 0