Skip to content

Commit c9e20dd

Browse files
committed
Fix issues in guides, and add PDFs for them
Issues fixed: - Use python3-pip instead of python-pip in the PDF - Use postgresql:// url instead of postgres:// since that's now deprecated - Ensure ToC links work properly
1 parent 8c4bc67 commit c9e20dd

9 files changed

+26
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ __pycache__/
55
*.db
66
.DS_Store
77
venv/
8+
.venv/

guides/DigitalOcean Tutorial.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
11
# Overview
22

3-
This is a tutorial on setting up a server on DigitalOcean, a cloud computing platform. We will walk through whole process from creating an account to setting up a server instance and connecting to it. The process should be similar for any cloud computing services. Once you set up your server on any platform of your choice the remaining deploying steps should be identical. Here is a tutorial that may serve as a general guide on deploying your Python app onto any hosting platforms: [How to Deploy Python App Using uWSGI and Nginx](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md).
4-
5-
# DigitalOcean
3+
This is a tutorial on setting up a server on DigitalOcean, a cloud computing platform. We will walk through whole process from creating an account to setting up a server instance and connecting to it. The process should be similar for any cloud computing services. Once you set up your server on any platform of your choice the remaining deploying steps should be identical. Here is a tutorial that may serve as a general guide on deploying your Python app onto any hosting platforms: [How to Deploy Python App Using uWSGI and Nginx](https://github.com/tecladocode/rest-apis-flask-python/blob/master/guides/How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.pdf).
64

75
DigitalOcean is a cloud infrastructure provider focused on simplifying web infrastructure for software developers. It allows you to rent servers with different performance at different cost. For more detailed information, you may refer to the official website help page [here](https://www.digitalocean.com/help/).
86

9-
# Creating an account
7+
## Creating an account
108

119
You can sign up to DigitalOcean using our affiliate link. Doing so gives you a starting credit of $10, which allows you to rent a server for 2 months. Click this link to create your account and get the $10: [https://m.do.co/c/d54c088544ed](https://m.do.co/c/d54c088544ed). If the link doesn't work, paste it into your browser.
1210

1311
![Create an account](assets/DigitalOcean/create_account.png)
1412

1513
After clicking the link, you should see a page like the above. Create your account at the left-bottom corner and you'll receive the $10 automatically. Beware that you'll be asked to provide payment info when creating the account, since all services (which you'll choose below) in DigitalOcean will be charged after your credit runs out.
1614

17-
# Creating a Droplet
15+
## Creating a Droplet
1816

1917
A server instance in DigitalOcean is called a `Droplet`. It's just a name that may vary in different platforms, for example, `Dyno` for `Heroku` and `EC2` for `AWS` (Amazon Web Service). Below are the steps to create a `Droplet`.
2018

21-
## Choosing an image
19+
### Choosing an image
2220

2321
To create a `Droplet`, we must first specify an image, that is, choosing what Operating System you want for the server. We recommend to use a Ubuntu LTS (Long Term Support) distribution. For more info on Ubuntu life time, please refer to the [official Ubuntu end of life page here](https://www.ubuntu.com/info/release-end-of-life). In our example, we'll use `Ubuntu 16.04.* x64`, which is an LTS distribution.
2422

2523
### Choosing a size
2624

2725
Next, we need to choose the specs for our server. In this tutorial, we'll be using the most basic tier of a Standard `Droplet`, which offers a single CPU with 512MB RAM, 20GB SSD and 1000 GB transfer at $5 per month. Generally, it's more than enough for running personal applications. You may also run several services in a single Droplet.
2826

29-
## Choosing a datacenter region
27+
### Choosing a datacenter region
3028

3129
Generally, choosing a region that's _closest to your users_ will make your service deliver faster. If your users are primarily in the United States, you could choose a United States-based Droplet.
3230

33-
## Other configurations
31+
### Other configurations
3432

3533
In our example, we do not need to add any other services such as block storage or private network. So we will ignore these settings to keep our setup simple and cheap. You may choose to use `SSH` key or you can just leave it unchecked and a password will be generated for you. If you choose to use SSH key, then each time you want to login to the server, you will need to provide the key. Since you have to have access to the SSH key whenever you log in, it can be more secure or more troublesome depends on scenarios. At last, you may change the name of your `Droplet` to something you like and then click `Create` to create and launch your `Droplet`.
3634

37-
# Connecting to our droplet
35+
## Connecting to our droplet
3836

3937
![DigitalOcean Access Console](assets/DigitalOcean/access_console.png)
4038

@@ -46,8 +44,8 @@ Now you will be shown a console connected to your `Droplet`. Use the login `root
4644

4745
If you have successfully followed the tutorial so far, then you have finished all the setting-ups that are specific to DigitalOcean. The following sections can serve as a standalone tutorial and can be applied to deployment onto any other platforms as well.
4846

49-
# Deploying application onto our server
47+
## Deploying application onto our server
5048

51-
After setting up our server (Droplet), the next thing we may want to do is to deploy our application onto the server. We will not, however, cover the process in this tutorial. Instead we recommend you to read this separate tutorial: [How to Deploy Python App Using uWSGI and Nginx](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md). We organize contents in such way because deployment is an independent process and should be similar on any platforms, not specific to DigitalOcean. So if you are curious, please check it out.
49+
After setting up our server (Droplet), the next thing we may want to do is to deploy our application onto the server. We will not, however, cover the process in this tutorial. Instead we recommend you to read this separate tutorial: [How to Deploy Python App Using uWSGI and Nginx](https://github.com/tecladocode/rest-apis-flask-python/blob/master/guides/How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.pdf). We organize contents in such way because deployment is an independent process and should be similar on any platforms, not specific to DigitalOcean. So if you are curious, please check it out.
5250

5351
Thanks for reading!

guides/DigitalOcean Tutorial.pdf

187 KB
Binary file not shown.

guides/Flask-JWT Configuration Tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Overview
1+
# Flask-JWT Configuration Tutorial
22

33
Flask-JWT adds JWT functionality to Flask in an easy to use manner. It gives you a lot of functionality out of the box, but sometimes we want to modify some of the configuration. This document walks through how to:
44

@@ -9,7 +9,7 @@ Flask-JWT adds JWT functionality to Flask in an easy to use manner. It gives you
99

1010
In addition, it covers how to retrieve the **currently logged in user** from any of our Flask app endpoints.
1111

12-
This tutorial assumes that you’ve followed the lectures and have set up Flask-JWT already! If you haven't done so yet, check out Section 5 of the [Udemy course](https://www.udemy.com/rest-api-flask-and-python/?couponCode=GITHUB).
12+
This tutorial assumes that you’ve followed the lectures and have set up Flask-JWT already! If you haven't done so yet, check out Section 5 of the [Udemy course](https://go.tecla.do/rest-apis-sale).
1313

1414
## Before We Start
1515

@@ -112,9 +112,9 @@ def customized_error_handler(error):
112112

113113
### Other Configurations
114114

115-
You may find out more configuration options here: https://pythonhosted.org/Flask-JWT/
115+
You may find out more configuration options here: [https://pythonhosted.org/Flask-JWT/](https://pythonhosted.org/Flask-JWT/)
116116

117-
Please refer to the \<Configuration Options> section.
117+
Please refer to the [Configuration Options](https://pythonhosted.org/Flask-JWT/#configuration-options) section.
118118

119119
## More
120120

60.3 KB
Binary file not shown.

guides/Heroku Tutorial.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Overview
22

3-
In this tutorial, we will introduce a popular cloud application platform called Heroku. We will briefly describe [what Heroku is](Heroku%20Tutorial.md#what-is-heroku) and [how to use it](Heroku%20Tutorial.md#deploying-our-app-onto-heroku).
3+
In this tutorial, we will introduce a popular cloud application platform called Heroku. We will briefly describe [what Heroku is](#what-is-heroku) and [how to use it](#deploying-our-app-onto-heroku).
44

55
# What is Heroku
66

77
Heroku is a cloud platform for deploying and running modern apps. A more detailed Introduction can be found [here](https://www.heroku.com/platform).
88

99
Some of the key advantages of Heroku include:
1010
- No server side knowledge is required, so it is easy to set up.
11-
- It can be free, but the free tier has some limitations, which we will discuss later when we introduce [`Dyno`](Heroku%20Tutorial.md#creating-a-heroku-dyno).
11+
- It can be free, but the free tier has some limitations, which we will discuss later when we introduce [`Dyno`](#creating-a-heroku-dyno).
1212
- It enables SSL so the communication between your app and its users are encrypted.
1313

1414

@@ -44,9 +44,9 @@ The first file we need to add is called `runtime.txt`. And it is **important** t
4444
python-3.5.2
4545
```
4646

47-
#### requirement.txt
47+
#### requirements.txt
4848

49-
The next file we need to add is called `requirement.txt`, which specifies all the dependencies of our project. So for our sample project, we will have something like this for the `requirement.txt` file:
49+
The next file we need to add is called `requirements.txt`, which specifies all the dependencies of our project. So for our sample project, we will have something like this for the `requirements.txt` file:
5050

5151
```
5252
Flask
@@ -57,7 +57,7 @@ uwsgi
5757
psycopg2
5858
```
5959

60-
Note that we are running a `Python` project, and `uWSGI` is used to run `Python` applications more efficiently and more reliably, providing features such as multi-threading and auto restarting after failure. If you are not running a `Python` app or you choose not to use `uWSGI`, it is totally fine and you can skip the next sub-section and go to the `Procfile` sub-section [here](Heroku%20Tutorial.md#procfile).
60+
Note that we are running a `Python` project, and `uWSGI` is used to run `Python` applications more efficiently and more reliably, providing features such as multi-threading and auto restarting after failure. If you are not running a `Python` app or you choose not to use `uWSGI`, it is totally fine and you can skip the next sub-section and go to the `Procfile` sub-section [here](#procfile).
6161

6262
#### uwsgi.ini \*
6363

guides/Heroku Tutorial.pdf

206 KB
Binary file not shown.

guides/How To Deploy Python App Using uWSGI And Nginx.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ In this tutorial, we will not cover how to set up a server on any hosting platfo
77
# Quick links
88
In this tutorial, we will assume you have a server set up already, and we will introduce the deployment process in the following order:
99

10-
- [Connecting to the server using `SSH`](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#connecting-to-our-server).
11-
- [Creating and configuring a `UNIX` user](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#creating-another-user).
12-
- [Setting up `PostgreSQL` database](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#configuring-postgres).
13-
- [Getting project code from `GitHub`](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#getting-code-from-github).
14-
- [Configuring `uWSGI` for our project](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#uwsgi).
15-
- [Configuring `nginx` for our project](How%20To%20Deploy%20Python%20App%20Using%20uWSGI%20And%20Nginx.md#nginx).
10+
- [Connecting to the server using `SSH`](#connecting-to-our-server).
11+
- [Creating and configuring a `UNIX` user](#creating-another-user).
12+
- [Setting up `PostgreSQL` database](#configuring-postgres).
13+
- [Getting project code from `GitHub`](#getting-code-from-github).
14+
- [Configuring `uWSGI` for our project](#uwsgi).
15+
- [Configuring `nginx` for our project](#nginx).
1616

1717
If you are a first time learner, we highly recommend you to follow through the whole tutorial so that you can get familiar with it and may be less likely to run into error. However, if you are only looking for information on a specific subject, please feel free to use the above links to navigate to according sections.
1818

@@ -331,7 +331,7 @@ And the content we are going to input is shown below:
331331
Description=uWSGI items rest
332332
333333
[Service]
334-
Environment=DATABASE_URL=postgres://johndoe:<johndoe_postgres_password>@localhost:5432/johndoe
334+
Environment=DATABASE_URL=postgresql://johndoe:<johndoe_postgres_password>@localhost:5432/johndoe
335335
ExecStart=/var/www/html/items-rest/venv/bin/uwsgi --master --emperor /var/www/html/items-rest/uwsgi.ini --die-on-term --uid johndoe --gid johndoe --logto /var/www/html/items-rest/log/emperor.log
336336
Restart=always
337337
KillSignal=SIGQUIT
217 KB
Binary file not shown.

0 commit comments

Comments
 (0)