Skip to content

Commit bb89653

Browse files
committed
Use Cloudinary for images so that content can be uploaded to teclado.ocm
1 parent 6736b77 commit bb89653

File tree

14 files changed

+41
-41
lines changed
  • docs/docs
    • 03_first_rest_api/05_make_request_to_rest_api
    • 04_docker_intro
    • 05_flask_smorest/05_reload_api_docker_container
    • 07_sqlalchemy_many_to_many/01_section_changes
    • 08_flask_jwt_extended
    • 11_deploy_to_render
    • 12_task_queues_emails

14 files changed

+41
-41
lines changed

docs/docs/03_first_rest_api/05_make_request_to_rest_api/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ Start by [downloading Insomnia REST Client](https://insomnia.rest/).
2929

3030
Once you've opened it, create a Project. I would call it "REST APIs with Flask and Python".
3131

32-
![Creating the Project for this course](assets/creating-project.png)
32+
![Creating the Project for this course](https://res.cloudinary.com/teclado/image/upload/v1689180715/courses/rest-apis-flask-python/creating-project_qsyxlg.png)
3333

3434
Then, create a new Request Collection. Call it "Stores REST API".
3535

36-
![Creating the Stores REST API Request Collection](assets/making-request-collection.png)
36+
![Creating the Stores REST API Request Collection](https://res.cloudinary.com/teclado/image/upload/v1689180710/courses/rest-apis-flask-python/making-request-collection_lcthlv.png)
3737

3838
In the Request Collection, we can now add requests! Each request has a few parts:
3939

@@ -46,19 +46,19 @@ Let's create our first request, `GET /store`.
4646

4747
Make a new request using the Insomnia interface. First, use the dropdown to start:
4848

49-
![How to make a request using the Insomnia interface](assets/making-request.png)
49+
![How to make a request using the Insomnia interface](https://res.cloudinary.com/teclado/image/upload/v1689180711/courses/rest-apis-flask-python/making-request_hmiptl.png)
5050

5151
Then enter the request name. Leave the method as `GET`:
5252

53-
![Enter the request name and method](assets/set-request-name-and-method.png)
53+
![Enter the request name and method](https://res.cloudinary.com/teclado/image/upload/v1689180712/courses/rest-apis-flask-python/set-request-name-and-method_bc6smy.png)
5454

5555
Once you're done, you will see your request in the collection:
5656

57-
![The request is shown in the collection](assets/before-setting-url.png)
57+
![The request is shown in the collection](https://res.cloudinary.com/teclado/image/upload/v1689180711/courses/rest-apis-flask-python/before-setting-url_qjxvyr.png)
5858

5959
Next up, enter the URL for your request. Here we will be requesting the `/store` endpoint. Remember to include your Base URL as well:
6060

61-
![Entering the full URL for the request in Insomnia](assets/url-set.png)
61+
![Entering the full URL for the request in Insomnia](https://res.cloudinary.com/teclado/image/upload/v1689180714/courses/rest-apis-flask-python/url-set_fgp9s9.png)
6262

6363
Once you're done, make sure that your Flask app is running! If it isn't, remember to activate your virtual environment first and then run the app:
6464

@@ -75,6 +75,6 @@ If you get an error, read it carefully and make sure that no other Flask app is
7575

7676
Once your Flask app is running, you can hit "Send" on the Insomnia client, and you should see the JSON come back from your API!
7777

78-
![Making a request to our API using Insomnia](assets/after-pressing-send.png)
78+
![Making a request to our API using Insomnia](https://res.cloudinary.com/teclado/image/upload/v1689180712/courses/rest-apis-flask-python/after-pressing-send_okjkjq.png)
7979

8080
If that worked and you can see your JSON, you're good to go! You've made your first API request. Now we can continue developing our REST API, remembering to always create new Requests in Insomnia and test our code as we go along!

docs/docs/04_docker_intro/01_what_is_docker_container/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ I'm sure you have heard of the term "Virtual Machine". A virtual machine is an e
88

99
This diagram shows what happens in that case:
1010

11-
![Virtual Machine Diagram stack](./assets/vm.drawio.png)
11+
![Virtual Machine Diagram stack](https://res.cloudinary.com/teclado/image/upload/v1689180716/courses/rest-apis-flask-python/vm.drawio_nlrxmx.png)
1212

1313
When you run a Virtual Machine, you can configure what hardware it has access to (e.g. 50% of the host's RAM, 2 CPU cores, etc).
1414

@@ -18,7 +18,7 @@ Containers have their own storage and networking, but because they don't have to
1818

1919
This diagram shows how Linux containers run in a Linux host:
2020

21-
![Docker Diagram stack](./assets/docker-linux.drawio.png)
21+
![Docker Diagram stack](https://res.cloudinary.com/teclado/image/upload/v1689180716/courses/rest-apis-flask-python/docker-linux.drawio_ebvff5.png)
2222

2323
Looks similar, but the `docker -> container` section is much more efficient than running a VM because it **uses the host's kernel** instead of running its own.
2424

docs/docs/04_docker_intro/03_run_docker_container/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ docker run -dp 5001:5000 rest-apis-flask-python
126126

127127
Try making requests using the URL `127.0.0.1:5000` with Insomnia REST Client or Postman, and you should see it working well!
128128

129-
![Insomnia REST Client successfully made a request to the API running in Docker](assets/running-app-docker.png)
129+
![Insomnia REST Client successfully made a request to the API running in Docker](https://res.cloudinary.com/teclado/image/upload/v1689180719/courses/rest-apis-flask-python/running-app-docker_mkosjm.png)
130130

131131
[^1]: [Docker `EXPOSE` command (Official Documentation)](https://docs.docker.com/engine/reference/builder/#expose)

docs/docs/05_flask_smorest/05_reload_api_docker_container/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ Using this kind of volume mapping only makes sense _during development_. When yo
102102

103103
Just to recap, here are the two ways we've seen to run your Docker container:
104104

105-
![Diagram showing two ways of running a Docker container from a built image, with and without volume mapping](./assets/build-with-without-volume.png)
105+
![Diagram showing two ways of running a Docker container from a built image, with and without volume mapping](https://res.cloudinary.com/teclado/image/upload/v1689180724/courses/rest-apis-flask-python/build-with-without-volume_a7mig8.png)

docs/docs/07_sqlalchemy_many_to_many/01_section_changes/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This means that tags will have:
3131

3232
Here's a diagram to illustrate what this looks like:
3333

34-
![ER database model showing relationships](./assets/db_model.drawio.png)
34+
![ER database model showing relationships](https://res.cloudinary.com/teclado/image/upload/v1689180742/courses/rest-apis-flask-python/db_model.drawio_ilgupm.png)
3535

3636
## New API endpoints to be added
3737

docs/docs/08_flask_jwt_extended/03_how_is_jwt_used/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Here is a diagram of the interaction between client and API to generate an acces
1818

1919
<div style={{maxWidth: '600px'}}>
2020

21-
![Diagram showing the flow between client and server to generate an access token](./assets/access-token-flow.drawio.png)
21+
![Diagram showing the flow between client and server to generate an access token](https://res.cloudinary.com/teclado/image/upload/v1689180750/courses/rest-apis-flask-python/access-token-flow.drawio_gdr9oo.png)
2222

2323
</div>
2424

@@ -56,7 +56,7 @@ Here is a rather long diagram depicting what happens:
5656

5757
<div style={{maxWidth: '600px'}}>
5858

59-
![Diagram showing flow of data when user wants to load their information but aren't logged in](./assets/my-info-flow.drawio.png)
59+
![Diagram showing flow of data when user wants to load their information but aren't logged in](https://res.cloudinary.com/teclado/image/upload/v1689180750/courses/rest-apis-flask-python/my-info-flow.drawio_pzfjh7.png)
6060

6161
</div>
6262

docs/docs/08_flask_jwt_extended/11_insomnia_request_chaining/README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@ Up until now, we've been able to log in, get an access token, and then use that
1212

1313
Instead of passing the JWT in every request, you can access the `Headers` section and follow these steps. In the `Authorization` field, type `Bearer` add a space and then press `CTRL + SPACE` to get a contextual menu. Navigate to the `Response -> Body Attribute` field and select it, as shown in the screenshot below:
1414

15-
![Contextual menu with Generator Tag options](./assets/bearer_token.png)
15+
![Contextual menu with Generator Tag options](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/bearer_token_qk2jqi.png)
1616

1717
After you've selected it, you'll see an error that looks like this:
1818

19-
![Response error in the Authorization field](./assets/error.png)
19+
![Response error in the Authorization field](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/error_darkak.png)
2020

2121
If you click on the error, you'll see a modal window:
2222

23-
![Modal window with empty fields](./assets/modal.png)
23+
![Modal window with empty fields](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/modal_xutepw.png)
2424

2525
Inside of this window, you will first need to select a request that you want to get the data from. Click on `Select item` inside the `Request` field and choose the `POST /login` endpoint. After you've done that, go to the `Filter` field. In this field, we are telling Insomnia which part of the response we want to get from it. The prompt is started with the dollar sign `$` and then we can use the dot to access the attributes of the response. If we only type `$` or `$.`, we'll get a list of all the attributes of the response:
2626

27-
![Attributes recieved from request using a dollar sign](./assets/attributes.png)
27+
![Attributes recieved from request using a dollar sign](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/attributes_kxngsi.png)
2828

2929
In our case, we want to get the `access_token` attribute from the response, so we type `$.access_token`. If there was something else inside the `access_token` that you wanted to access like some value for example, you could do `$.access_token.value` and so on. After you've added the filter, you can set the `Trigger Behavior`. For example, you can set it to `When expired` and set time to 300 seconds. This means that the token will be refreshed every 5 minutes. The filled out window should look like this:
3030

31-
![Filled out modal window with attributes recieved from request using a dollar sign followed by .access_token](./assets/filled_out.png)
31+
![Filled out modal window with attributes recieved from request using a dollar sign followed by .access_token](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/filled_out_muzo2u.png)
3232

3333
You can now press `Done` and you'll see that the error is gone and that the `Authorization` field is filled out with the `Bearer` token:
3434

35-
![Filled out Authorization field with Bearer token](./assets/token.png)
35+
![Filled out Authorization field with Bearer token](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/token_txc8sb.png)
3636

3737
Since we use multiple protected endpoints, we would need to use the same method to get the `access_token` for every request. To tackle this problem, we can use [environment variables](https://support.insomnia.rest/article/13-environment-variables), as we did before for the `url` variable.
3838

3939
To do this, you need to create a new environment variable. Click on the `No Environment` button in the top left corner of the Insomnia window and then click on the `Manage Environments` button, you will see a base environment that looks like this:
4040

41-
![Base environment with url environment variable only](./assets/base_environment.png)
41+
![Base environment with url environment variable only](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/base_environment_cfyrab.png)
4242

4343
Add a new environment variable called `access_token`, and for its value you should follow the same process from above. As a quick reminder, you should press `CTRL + SPACE` to get the contextual menu and then select the `Response -> Body Attribute` field. Click on the error that will show up and fill out the modal window as we've done before. Make sure to wrap the `Response -> Body Attribute` with quotation marks, as shown in the screenshot. When the variable is created, your environment should look like this:
4444

45-
![Base environment with added access_token variable](./assets/environment.png)
45+
![Base environment with added access_token variable](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/environment_n8jfm9.png)
4646

4747
You will now be able to use this environment variable in all of the endpoints by simply writing `{{access_token}}` in the field that you want to use it in. Coming back to the first example, you can use the access token in the `Authorization` field by writing `Bearer {{access_token}}` and this will be the result:
4848

49-
![Bearer with access_token environment variable](./assets/result.png)
49+
![Bearer with access_token environment variable](https://res.cloudinary.com/teclado/image/upload/v1689180763/courses/rest-apis-flask-python/result_krbno3.png)
5050

5151
If you try and make the request, you will see that it works just like before, without needing to copy and paste the access token.

docs/docs/11_deploy_to_render/02_create_render_web_service/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ Then you'll [connect your GitHub account](https://render.com/docs/github) if you
1616

1717
Select the repository that you created during this course:
1818

19-
![Render.com screenshot showing how to search for and select a repository to connect to from GitHub](./assets/render-github-connect.png)
19+
![Render.com screenshot showing how to search for and select a repository to connect to from GitHub](https://res.cloudinary.com/teclado/image/upload/v1689180776/courses/rest-apis-flask-python/render-github-connect_jp6mip.png)
2020

2121
Then, give it a name and make sure the configuration is as follows:
2222

23-
![Render.com screenshot showing the web service configuration](./assets/render-service-config.png)
23+
![Render.com screenshot showing the web service configuration](https://res.cloudinary.com/teclado/image/upload/v1689180776/courses/rest-apis-flask-python/render-service-config_poweeb.png)
2424

2525
- Make sure "Docker" is selected.
2626
- Select a server location close to you. I'm near Frankfurt, but if you are in the US or Asia you might want to choose a different one so it's faster to connect to.
@@ -32,19 +32,19 @@ For now, hit "Create Web Service" and wait for it to deploy your code from GitHu
3232

3333
If you navigate to your Dashboard and then click through to your newly created service, you'll be able to see the service details. If it isn't already deploying, click on the "Manual Deploy" button on the top right to initiate a deploy of the latest commit:
3434

35-
![](./assets/deploy-latest-commit.png)
35+
![](https://res.cloudinary.com/teclado/image/upload/v1689180775/courses/rest-apis-flask-python/deploy-latest-commit_k9as13.png)
3636

3737
Then you should start seeing logs appear detailing the deployment process!
3838

39-
![](./assets/render-deploy-screen.png)
39+
![](https://res.cloudinary.com/teclado/image/upload/v1689180776/courses/rest-apis-flask-python/render-deploy-screen_lfx1uh.png)
4040

4141
While on the free plan, deployments are a bit slow. It has to build your image and run it! Give it a few minutes, until the deployment succeeds. You should see this:
4242

43-
![](./assets/render-deploy-finished.png)
43+
![](https://res.cloudinary.com/teclado/image/upload/v1689180776/courses/rest-apis-flask-python/render-deploy-finished_lyiftz.png)
4444

4545
Now, you can access your service URL and try it out using Insomnia or Postman!
4646

47-
![](./assets/insomnia-test-prod.png)
47+
![](https://res.cloudinary.com/teclado/image/upload/v1689180778/courses/rest-apis-flask-python/insomnia-test-prod_dlfe1d.png)
4848

4949
:::warning
5050
Free services in Render.com shut down after inactivity for a few minutes. If you don't use your service for a few minutes, it will shut down and it will need to restart, which can take a minute! This is one of the limitations of their free plan.

docs/docs/11_deploy_to_render/04_deploy_postgresql_database/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ That's why I recommend using ElephantSQL for your free PostgreSQL needs. When yo
1212

1313
To get a free ElephantSQL PostgreSQL database, just go to their site, sign up, and then create a database in a region close to your Render.com server. Make sure to select the free tier.
1414

15-
![ElephantSQL screenshot showing plan configuration of Tiny Turtle (free) and name](./assets/select-plan-and-name-elephantsql.png)
15+
![ElephantSQL screenshot showing plan configuration of Tiny Turtle (free) and name](https://res.cloudinary.com/teclado/image/upload/v1689180780/courses/rest-apis-flask-python/select-plan-and-name-elephantsql_sx3v2e.png)
1616

1717
Once you've got this, you should be able to see the Database URL:
1818

19-
![ElephantSQL screenshot showing that a copy icon beside the Database URL can be clicked to copy it](./assets/copy-elephantsql-url.png)
19+
![ElephantSQL screenshot showing that a copy icon beside the Database URL can be clicked to copy it](https://res.cloudinary.com/teclado/image/upload/v1689180780/courses/rest-apis-flask-python/copy-elephantsql-url_ydr90k.png)
2020

2121
Copy this, as you'll need it in the next lecture!

docs/docs/11_deploy_to_render/05_environment_variables_and_migrations/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,11 @@ Now that our Flask app is using environment variables, all we have to do is add
360360

361361
To add environment variables in Render.com, go to the service settings and then on the left you'll see "Environment":
362362

363-
![Render.com screenshot showing the button to add a environment variables](./assets/render-add-env-var.png)
363+
![Render.com screenshot showing the button to add a environment variables](https://res.cloudinary.com/teclado/image/upload/v1689180783/courses/rest-apis-flask-python/render-add-env-var_lodpee.png)
364364

365365
Click on "Add Environment Variable", and there put `DATABASE_URL` as the key, and your ElephantSQL Database URL as the value:
366366

367-
![Render.com screenshot showing DATABASE_URL added with a pixelated value](./assets/render-database-url-env-var.png)
367+
![Render.com screenshot showing DATABASE_URL added with a pixelated value](https://res.cloudinary.com/teclado/image/upload/v1689180784/courses/rest-apis-flask-python/render-database-url-env-var_wrxgjl.png)
368368

369369
:::warning
370370
Again, make sure to use `postgresql://...` here.

docs/docs/12_task_queues_emails/01_send_emails_python_mailgun/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You will get an email to confirm. Click the button that you see in that email to
3838

3939
Next up, grab your API key. You can find it by clicking on this button (my domain and API key are blurred in this screenshot):
4040

41-
![Click the 'Select' button to reveal your Mailgun API key](./assets/mailgun-api-key.png)
41+
![Click the 'Select' button to reveal your Mailgun API key](https://res.cloudinary.com/teclado/image/upload/v1689180789/courses/rest-apis-flask-python/mailgun-api-key_mc8bjz.png)
4242

4343
## Sending emails with Mailgun
4444

docs/docs/12_task_queues_emails/03_what_is_task_queue/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ctslug: what-is-a-task-queue
66

77
A queue is a data structure to which you can add and remove data, but a key aspect of it is that when you want to remove a piece of data from it, the piece of data removed is the first piece of data that was added.
88

9-
![New elements are added at the end, called pushing, and removed from the start, called popping, of a queue](./assets/queues.drawio.png)
9+
![New elements are added at the end, called pushing, and removed from the start, called popping, of a queue](https://res.cloudinary.com/teclado/image/upload/v1689180793/courses/rest-apis-flask-python/queues.drawio_yqgtvg.png)
1010

1111
This is identical to how people queuing works. The first person to arrive at the queue (i.e. the first in line), is the first person removed from the queue when they reach the ticket counter.
1212

@@ -32,6 +32,6 @@ Later on if we want, we can upgrade to one of the paid plans.
3232

3333
To be able to add tasks to the queue from your dev environment, make sure to [allow external connections](https://render.com/docs/redis#connecting-to-your-redis-from-outside-render) in your Redis database configuration.
3434

35-
![Screenshot showing 0.0.0.0/0 as an allowed IP address when connecting to our Render Redis database](./assets/render-redis-allowing-outside.png)
35+
![Screenshot showing 0.0.0.0/0 as an allowed IP address when connecting to our Render Redis database](https://res.cloudinary.com/teclado/image/upload/v1689180794/courses/rest-apis-flask-python/render-redis-allowing-outside_tkxsls.png)
3636

3737
You should get a Redis URL that looks like this: `rediss://red-ct8aen0hkl10:[email protected]:6379`. Save it, for we'll need it in the next lecture!

docs/docs/12_task_queues_emails/06_sending_html_emails/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Now remember to restart your app _and_ your background worker, then try to regis
255255

256256
You should get the HTML email delivered!
257257

258-
![HTML email with button to go to the API documentation](./assets/html-email.png)
258+
![HTML email with button to go to the API documentation](https://res.cloudinary.com/teclado/image/upload/v1689180798/courses/rest-apis-flask-python/html-email_dyxasi.png)
259259

260260
:::info Spam or junk?
261261
If your emails are going to spam, it's likely because you're using the sandbox domain. When you use an actual domain, you have to go through various [domain verification steps](https://help.mailgun.com/hc/en-us/articles/360011702394-Why-Do-My-Emails-Go-to-Spam-) which reduce the likelihood of your emails ending up in spam.

0 commit comments

Comments
 (0)