Request Routing

Learn how to route requests in Flask.

Before we create a RabbitMQ producer and consumer for the Core app, we must correctly route requests in the app. In Flask, a request is an object bearing all the data a client sends to a server. We can access this data using the HTTP GET or POST methods.

The POST method is usually employed when we expect user inputs as part of the HTTP request to our web application. However, if we do not expect any user input to be received by our application, the HTTP GET method is used. There are other HTTP methods as well, but in the Core app, we'll only use the GET method for the home route and the POST method for other routes where we expect the user (checker) to make inputs (likes or checks) to our real estate web app through this microservice.

Routing requests in the Core app

To route requests in our Core app, we'll open backendservice2/core.py. We'll also import jsonify and abort from flask, and import requests, as follows:

from flask import jsonify, abort
import requests

Once we're done with the imports, we can start creating the routes for the index, like, and check style actions that will provide the GET or POST HTTP methods of ...