File tree Expand file tree Collapse file tree 10 files changed +0
-20
lines changed
Building the Gateway Application
Add a Dockerfile and requirements.txt Expand file tree Collapse file tree 10 files changed +0
-20
lines changed Original file line number Diff line number Diff line change 1
- ## Add Dockerfile and requirements.txt
2
-
3
1
### Task
4
2
Add the files necessary to run the gateway app as a Docker container.
5
3
Original file line number Diff line number Diff line change 1
- ## Define Routes
2
-
3
1
We added the four functions needed in our gateway application for routing requests (in addition to ` index() ` , which doesn't really do anything).
4
2
Each of these four functions will send a request to the other application.
5
3
In this task, you will add the appropriate routes to all of them.
Original file line number Diff line number Diff line change 1
- ## Delete Resource
2
-
3
1
In this task, we will define the ` delete_device ` function, which will:
4
2
- Forward the delete request to the relevant endpoint in ` invsys ` .
5
3
- Forward the response back to the client by creating a ` Response ` object from the received ` response ` .
Original file line number Diff line number Diff line change 1
- ## Get Devices
2
-
3
1
In this task, we will define the ` get_devices ` function, which will:
4
2
- Forward the request to the relevant endpoint in ` invsys ` (depending on the URL: if the item ID is provided,
5
3
it needs to be added to the route, which in ` invsys ` will result in calling the ` get ` endpoint in the function ` device ` )
Original file line number Diff line number Diff line change 1
- # Gateway Application
2
-
3
1
The next step will be creating an API gateway backend, which acts as a router for client requests.
4
2
This means our final application will consist of two backend components: the inventory
5
3
manager and the API gateway.
Original file line number Diff line number Diff line change 1
- ## POST Resource
2
-
3
1
In this task, we will define the ` post_device ` function, which will:
4
2
- Get the payload from our incoming request.
5
3
- Forward the POST request to the relevant endpoint in invsys. Do not forget the payload!
Original file line number Diff line number Diff line change 1
- ## Put Resource
2
-
3
1
In this task we will define the ` put_device ` function, which will:
4
2
- Get the payload from our incoming request.
5
3
- Forward the PUT request to the relevant endpoint in ` invsys ` . Do not forget the payload!
Original file line number Diff line number Diff line change 1
- ## Deploying locally without Docker
2
-
3
-
4
1
While this course is focused on deploying with Docker, you can also deploy locally without it.
5
2
6
3
You will need to change the routes in the ` gateway ` :
Original file line number Diff line number Diff line change 1
- ## Composing our system
2
1
Now we have two Flask apps: Invsys and Gateway.
3
2
We want them both to be deployed, and we want Gateway to be able to send
4
3
requests to Invsys using ` invsys ` instead of a specific IP.
Original file line number Diff line number Diff line change 1
- ## What else to explore
2
-
3
1
Here are some recommended resources for further reading:
4
2
5
3
[ Flask by example: Part 1] ( https://realpython.com/flask-by-example-part-1-project-setup/ ) — a tutorial.
You can’t perform that action at this time.
0 commit comments