Skip to content

Commit 433b93b

Browse files
authored
Merge pull request #59 from jknox927/fixing-learnpack-and-readme
Fixing learnpack and readme
2 parents 5a445c0 + fd12509 commit 433b93b

File tree

15 files changed

+88
-73
lines changed

15 files changed

+88
-73
lines changed

.learn/exercises/00-intro/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DELETE /todos/<int:position>
1010

1111
## **GET /todos**
1212

13-
It will return the list of all todos like this:
13+
It will return the list of all todos in a JSON format like this:
1414

1515
```javascript
1616
[
@@ -27,7 +27,7 @@ It will return the list of all todos like this:
2727

2828
## **POST /todos**
2929

30-
It's going to add a new todo to the list by sending the following request body:
30+
The POST method is going to add a new todo to the list by sending the following request body:
3131

3232
```javascript
3333
{
@@ -57,4 +57,4 @@ And then, it returns the updated list of todos:
5757

5858
## **DELETE /todos/<int:position>**
5959

60-
It's going to remove one todo based on a given position at the end of the url, and return the updated list of todos.
60+
The DELETE method is going to remove one todo based on a given position at the end of the url, and return the updated list of todos.

.learn/exercises/01-hello-world/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Hello World with Flask
22

3-
During this tutorial, we'll be building a REST API using Python programming language and the [Flask library](https://flask.palletsprojects.com/en/1.1.x/) (ideal for creating APIs).
3+
During this tutorial, we'll be building a REST API using the Python programming language and the [Flask library](https://flask.palletsprojects.com/en/1.1.x/) (ideal for creating APIs).
44

55
But we are going to do it the right way! Following all the good practices, we have to install and learn some things first.
66

@@ -16,7 +16,7 @@ If you are building this project using Gitpod, you don't have to install anythin
1616

1717
1. Open a new terminal (leave this one open)
1818

19-
2. Make sure you have python version 3:
19+
2. Make sure you have python version 3 by running the following commands:
2020

2121
```bash
2222
$ python --version
@@ -31,7 +31,7 @@ $ python3 --version
3131

3232
3. Make sure you have pipenv installed:
3333

34-
Instead of using Pip and virtual env, we are going to be using Pipenv: A combination of both technologies that will make your life much easier.
34+
Instead of using Pip and virtual env separately, we are going to be using Pipenv: A combination of both technologies that will make your life much easier.
3535

3636
```bash
3737
$ pipenv --version

.learn/exercises/02-pipenv-installation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Every python project should be wrapped in a "virtual environment" to ensure that
1414
$ pipenv install --python 3
1515
```
1616

17-
You should see a **PipFile** on the root of your project and it should have inside a **[requires]** for python version 3+ similar to this one (but maybe with a different python 3 version).
17+
You should see a **PipFile** on the root of your project and it should have a **[requires]** inside of it for python version 3+: similar to this one (but maybe with a different python 3 version).
1818

1919
![Pipfile preview](../../assets/pipfile.png?raw=true)
2020

.learn/exercises/03-first-flask-app/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ Flask is an app that behaves like a web server: it exposes (publishes) a group o
55
For example, you can use Flask with a domain and expose the following URLs to the internet:
66

77
```txt
8-
myporfolio.com/home
9-
myporfolio.com/about-me
10-
myporfolio.com/contact-me
8+
mywebsite.com/home
9+
mywebsite.com/about-me
10+
mywebsite.com/contact-me
1111
```
1212

13-
Those three URLs exposed by Flask will become your personal portfolio website.
13+
Those three URLs exposed by Flask will become your personal website.
1414

15-
To create our first server, we need to add the following two lines to any python file:
15+
To create our first server, we need to add the following two lines to our python file that we are going to create (These two lines have to be in every flask project you create to work correctly):
1616

1717
```python
1818
from flask import Flask
@@ -22,6 +22,6 @@ app = Flask(__name__)
2222

2323
1. On the root of your project create a `src` folder.
2424

25-
2. Inside of it, create a file `src/app.py`.
25+
2. Inside of it, create a file named `app.py`.
2626

2727
3. As instructed above, add the code to create a new flask app.

.learn/exercises/03.1-app-run/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
After creating our app, we need to run and start the application.
44

5-
When the application runs it will take over your command line, you will not be able to type on it anymore because a server application (like flask) never stops running, it keeps waiting for "requests" forever.
5+
When the application runs, it will take over your command line and you will not be able to type on it anymore because a server application (like flask) never stops running. It keeps waiting for "requests" forever.
66

77
## 📝 Instructions:
88

9-
1. Add the following lines to the end of your `src/app.py` file:
9+
1. Add the following lines at the bottom of your `app.py` file (Remember, this should be inside of your `src` folder on the root directory):
1010

1111
```python
1212
# These two lines should always be at the end of your app.py file.
@@ -16,7 +16,7 @@ if __name__ == '__main__':
1616

1717
> These two lines should always be at the very end of your file.
1818
19-
Run your new server by opening a **new separate terminal** and enter the following command:
19+
To run your new server, open a **new separate terminal** and enter the following command:
2020

2121
```bash
2222
$ pipenv run python src/app.py
@@ -25,3 +25,6 @@ $ pipenv run python src/app.py
2525
> Open a new terminal to run this command.
2626
2727
![Running Terminal](../../assets/running-flask-app.gif?raw=true)
28+
29+
## Command Explanation:
30+
We use our combined `pipenv` command to start up our virtual environment and `run` it using `python`. Our target file for starting our server for future requests is our `src/app.py`.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# `03.2` Check for Live URL
22

3-
It looks like your API is running live!
4-
5-
You can check it out by clicking on the URL (that was displayed on the command line) once Flask started running like this:
3+
You can check to see if your server is running by clicking on the URL (this is displayed on the command line) once Flask has started running like the GIF below:
64

75
![Check Flask Live](../../assets/live-api.gif?raw=true)
86

9-
Once you open it successfully, your live API should say `Not Found` like this:
7+
It looks like your API is running live!
8+
9+
Once you open it successfully, your live API should say `Not Found` like this image:
1010

1111
![Not found API](../../assets/not-found.png?raw=true)
1212

13-
The reason the API says `Not found` right now is because we have not added any endpoints so far. Now we have to start adding endpoints!
13+
The reason the API says `Not found` right now is because we have not added any endpoints so far meaning, there is no data being fetched or sent. Now that we have our server up and running, let's start adding some endpoints!

.learn/exercises/03.3-your-first-route/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# `03.3` You first Endpoint (route)
1+
# `03.3` Creating Your First Endpoint (route)
22

3-
Being Flask a server, it does not make sense not to add any URLs to expose over the internet, for example:
3+
Since Flask is a server, it only makes sense to add some URLs to expose over the internet, for example: mydomain.com/hello
44

5-
As a developer, if we would like for people to visit http://mydomain.com/hello and get a message `Hello World`, we would have to add the following endpoint to the app.py file:
5+
As a developer, if we would like people to visit `http://mydomain.com/hello` and show a message like `Hello World` to those people, we have to add the following endpoint inside our app.py file:
66

77
```python
8-
@app.route('/blabla', methods=['GET'])
8+
@app.route('/myroute', methods=['GET'])
99
def hello_world():
1010
return 'Hello, World!'
1111
```
1212

13-
+ The first line `@app.route('/blabla')` specifies the enpoint that will be available from now on, in this case `mydomain.com/blabla`.
13+
+ The first part, `@app.route('/myroute')`, specifies the enpoint that will be available to our users. In this case, users would see `mydomain.com/myroute` when visiting this route.
1414

15-
+ The first line also specifies the methods that will be used with that URL, in this case `GET` method (for reading).
15+
+ The first line also specifies the methods that will be used with that URL. In this case, the `GET` method (for reading data).
1616

1717
+ The second line defines a function that will be called by Flask when that endpoint is called by the user (when the user requests `/blabla`).
1818

19-
+ The third line returns the text: "Hello World" to the requesting client or browser.
19+
+ The third line defines our function execution and in this case, returns the text "Hello World" to the requesting client or browser.
2020

2121
## 📝Instructions:
2222

2323
1. Using that knowledge, make your server return the string `"<h1>Hello!</h1>"` when the URL `/todos` is typed on the browser.
2424

25-
2. Please make sure that this lines keep being the last two lines of your `app.py` file.
25+
2. Please make sure that these two lines stay at the bottom of your `app.py` file. All routing and functions must remain above these two lines.
2626

2727
```python
2828
if __name__ == '__main__':

.learn/exercises/04-runnig-flask/README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# `04` Demo your API!!
22

3-
Congratulations! Your first endpoint is LIVE now! Probably at:
3+
Go ahead and check your API endpoint by typing this URL on your browser and you should see the `Hello!` message like this:
4+
5+
![Demo your API](../../assets/check-live.gif?raw=true)
6+
7+
Congratulations! Your first endpoint is now LIVE!
8+
9+
## Your URL will be one of two options:
10+
11+
If running through Gitpod, just add `/todos` to the end of your URL in the browser:
12+
13+
```txt
14+
GET https://yourgitpodurl:3245/todos
15+
```
16+
17+
If running locally:
418

519
```txt
620
GET https://localhost:3245/todos
721
```
822

9-
Go ahead and check for your API endpoint by typing this URL on your browser and you should see the `Hello!` message like this:
1023

11-
![Demo your API](../../assets/check-live.gif?raw=true)

.learn/exercises/05-returning-json/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ You can use the [flask jsonify](https://flask.palletsprojects.com/en/1.1.x/api/#
99
# add the jsonify method to your Flask import
1010
from flask import Flask, jsonify
1111

12-
# suppose you have your data in the variable some_data
12+
# suppose you have your data in the variable named some_data
1313
some_data = { "name": "Bobby", "lastname": "Rixer" }
1414

15-
@app.route('/blahblah', methods=['GET'])
15+
@app.route('/myroute', methods=['GET'])
1616
def hello_world():
1717
# you can convert that variable into a json string like this
1818
json_text = jsonify(some_data)
@@ -21,7 +21,7 @@ def hello_world():
2121
return json_text
2222
```
2323

24-
If we apply this knowledge to our ToDo-list project we can create a global variable `todos` that will contain the list of todos like this:
24+
If we apply this knowledge to our ToDo-list project, we can create a global variable named `todos` that will hold the list of todos like this:
2525

2626
```python
2727
todos = [
@@ -32,10 +32,10 @@ todos = [
3232

3333
## 📝Instructions:
3434

35-
1. Create a global variable todos. Do not declare the variable inside any function, make sure to declare the variable anywhere at the global scope. Make sure the variable contains at least one task item inside with the following structure:
35+
1. Create a global variable called `todos`. Do not declare the variable inside any function. Declare the variable in the global scope and make sure the variable contains at least one task item (our task objects) inside with the following structure:
3636

3737
```python
3838
[ { "label": "My first task", "done": False } ]
3939
```
4040

41-
2. Change the function that is executed on the GET method's endpoint to make it return the jsonified version of the global variable `todos`.
41+
2. Change the function on the GET method's endpoint from string output so that it will return the jsonified version of the global variable `todos`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# `06` Check the API
22

3-
Now you can check your endpoint live. It should be returning the list of todos like this:
3+
Now you can check your endpoint live in the browser. It should be returning the list of todos in JSON format like this:
44

55
![check live todos](../../assets/return_todos.gif?raw=true)

0 commit comments

Comments
 (0)