Micro Services Classroom Series – 12/Nov/2021

Flask Web Framework

  • It is a web framework that can be used to easily build Web Applications.
  • Web applications usually need core functionalities such as interacting with client requests, routing URLs to resources, rendering web pages and interacting with databases.
  • Flask provides the necessary packages, modules that do the heavy lifting & as a develepor we need to focus on the acutal application logic.
  • The reason why we choose the Flask is that Flask is minimalistic (Also regarded as micro web framework)
  • If we want to build further functions, there is vast number of Flask extensions.

Building a Simple Recipe Management Application

  • We are going to build a recipe-sharing platform and API is the interface we expose to the public.
  • Lets start with Basic functions that we will need
HTTP Method Functionality URI
GET Get all the recipes /recipes
GET Get one particular recipe /recipe/11
POST Create a recipe /recipes
PUT Update a recipe /recipes/11
DELETE Delete a recipe /recipes/11
  • The typical recipe should have the following attributes

    • ID: The unique identifier for the recipe
    • Name: The name of the recipe
    • Description: The description of the recipe
  • Lets create a new project or use the project created in the last session.

  • Ideally recipes should be coming from database. Till we write database code to this lets use static responses

  • Lets refer the documentation of Flask API reference Refer Here

  • Lets try to send the responses in json format

  • Refer Here for the changes done

  • Refer Here for the postman collection added

  • Refer Here for the code changes to get individual recipe.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin