add code fence support and fix a ton of lint issues

This commit is contained in:
ducoterra
2020-11-05 14:47:29 -05:00
parent 360bd07a44
commit 8014742933
3 changed files with 111 additions and 105 deletions

View File

@@ -38,9 +38,9 @@ Before we can dive into our web project we have to cover some Python basics. Let
15. Type `address` and press enter. You should see the address print to the terminal. Tuples can hold multiple types of data - 123 is a number and "lane ave" is a string.
16. Type `len(address)` and press enter. You should see `5` printed to the terminal. There are 5 "things" in the tuple:
16. Type `len(address)` and press enter. You should see `5` printed to the terminal. There are 5 "things" in the tuple:
(1) `123 `
(1) `123`
(2) `"lane ave"`
@@ -72,22 +72,21 @@ Before we can dive into our web project we have to cover some Python basics. Let
![open_file](img/day1/open_file.png)
1. In this file type `print('hello, world!')` and save with <kbd>ctrl</kbd>+<kbd>S</kbd>
2. In this file type `print('hello, world!')` and save with ++ctrl++ + S
![type_hw](img/day1/type_hw.png)
1. In the terminal type `python my_program.py` and press enter. You should see `hello, world!` printed to the terminal.
3. In the terminal type `python my_program.py` and press enter. You should see `hello, world!` printed to the terminal.
![run_hw](img/day1/run_hw.gif)
1. Congratulations! You ran your first python file. Just like the python command prompt above, running `python <filename>` on a file with python code in it will execute that python code. Now we can run multiple lines of python at once!
4. Congratulations! You ran your first python file. Just like the python command prompt above, running `python <filename>` on a file with python code in it will execute that python code. Now we can run multiple lines of python at once!
1. Below `print('hello, world!')` type `print('goodbye!)`
5. Below `print('hello, world!')` type `print('goodbye!)`
![print_goodbye](img/day1/print_goodbye.png)
1. Below `print('goodbye')` type
6. Below `print('goodbye')` type
```python
x = 1
@@ -99,7 +98,7 @@ Before we can dive into our web project we have to cover some Python basics. Let
![type_more_code](img/day1/type_more_code.png)
1. Save the file with <kbd>ctrl</kbd>+<kbd>S</kbd>. In your terminal type `python myprogram.py` and press enter. You should see
7. Save the file with ++ctrl++ + S. In your terminal type `python myprogram.py` and press enter. You should see
```bash
hello, world!
@@ -110,29 +109,29 @@ Before we can dive into our web project we have to cover some Python basics. Let
printed to the terminal
1. This is out of order. We want to print "goodbye" last. Let's fix that with functions.
8. This is out of order. We want to print "goodbye" last. Let's fix that with functions.
1. Above `print('hello, world!')` type `def print_hello():`
9. Above `print('hello, world!')` type `def print_hello():`
![def_ph](img/day1/def_ph.png)
1. Indent `print('hello, world!')` by pressing <kbd>tab</kbd>
10. Indent `print('hello, world!')` by pressing ++tab++
![indent_hw](img/day1/indent_hw.png)
1. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
11. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
![print_gb](img/day1/print_gb.png)
1. Finally add `def middle_stuff():` above the remaining cod
12. Finally add `def middle_stuff():` above the remaining cod
![middle_stuff](img/day1/middle_stuff.png)
1. Save the file with <kbd>ctrl</kbd>+<kbd>S</kbd>. Now type `python my_program.py` in the terminal and press enter. Nothing will return.
13. Save the file with ++ctrl++ + S. Now type `python my_program.py` in the terminal and press enter. Nothing will return.
![functions_in_order](img/day1/functions_in_order.png)
1. We've given our snippets of code "names" by adding a "def" above them. These are called functions. We can call them in any order we want. Let's call them in the correct order by using their names. Add the following to the bottom of my_program.py
14. We've given our snippets of code "names" by adding a "def" above them. These are called functions. We can call them in any order we want. Let's call them in the correct order by using their names. Add the following to the bottom of my_program.py
```python
print_hello()
@@ -140,7 +139,7 @@ Before we can dive into our web project we have to cover some Python basics. Let
print_goodbye()
```
1. Type `python my_program.py` in the terminal and press enter. Now everything prints in order!
15. Type `python my_program.py` in the terminal and press enter. Now everything prints in order!
![in_order](img/day1/in_order.png)
@@ -150,88 +149,90 @@ Now that we can write some basic python we can begin our django project. Let's s
1. Close out of my_program.py
1. In the terminal type `django-admin startapp mysite`
2. In the terminal type `django-admin startapp mysite`
![startapp](img/day1/startapp.gif)
1. Expand the `config` folder by clicking on it
3. Expand the `config` folder by clicking on it
![config](img/day1/config.png)
1. Click on `settings.py` to open it
4. Click on `settings.py` to open it
1. Scroll down to line 33 and add `mysite` above `'django.contrib.admin'`
5. Scroll down to line 33 and add `mysite` above `'django.contrib.admin'`
![add_mysite](img/day1/add_mysite.png)
1. Save with <kbd>ctrl</kbd>+<kbd>S</kbd>
6. Save with ++ctrl++ + S
1. Click on `urls.py` to open it
7. Click on `urls.py` to open it
![urls](img/day1/urlspy.png)
1. On line 17 add `, include` after `from django.urls import path`
8. On line 17 add `, include` after `from django.urls import path`
![include](img/day1/include.png)
1. Add `path('', include('mysite.urls')),` above `path('admin/', admin.site.urls),`
9. Add `path('', include('mysite.urls')),` above `path('admin/', admin.site.urls),`
![mysiteurls](img/day1/mysiteurls.png)
1. Expand the newly created `mysite` folder by clicking on it
10. Expand the newly created `mysite` folder by clicking on it
![mysite](img/day1/mysite.png)
1. Right click on `mysite` and click "New Folder". Name it `templates`
11. Right click on `mysite` and click "New Folder". Name it `templates`
![templates](img/day1/templates.gif)
1. Right click on `templates` and click "New Folder". Name it `mysite`
12. Right click on `templates` and click "New Folder". Name it `mysite`
![mysitetemplate](img/day1/mysitetemplates.gif)
1. Right click on the `mysite` folder inside `templates` and click "New File". Name it `index.html`
13. Right click on the `mysite` folder inside `templates` and click "New File". Name it `index.html`
![index](img/day1/index.gif)
1. Open `index.html` by clicking on it
14. Open `index.html` by clicking on it
1. Add the following to index.html
15. Add the following to index.html
```html
<!DOCTYPE html>
<body>
{{ data }}
</body>
</html>
```
![indexdata](img/day1/indexdata.png)
1. Save with <kbd>ctrl</kbd>+<kbd>S</kbd>
16. Save with ++ctrl++ + S
1. Open `views.py` by clicking on it
17. Open `views.py` by clicking on it
1. In views.py under line 3 add the following:
18. In views.py under line 3 add the following:
```python
def index(request):
return render(
request,
"mysite/index.html",
request,
"mysite/index.html",
{"data": "hello"}
)
```
![defindex](img/day1/defindex.png)
1. Save with <kbd>ctrl</kbd>+<kbd>S</kbd>
19. Save with ++ctrl++ + S
1. Right click on `mysite` and click "New File". Name it `urls.py`
20. Right click on `mysite` and click "New File". Name it `urls.py`
![createurls](img/day1/createurls.gif)
1. Add the following to urls.py:
21. Add the following to urls.py:
```python
from django.urls import path
@@ -244,14 +245,14 @@ Now that we can write some basic python we can begin our django project. Let's s
![indexpath](img/day1/indexpath.png)
1. Save with <kbd>ctrl</kbd>+<kbd>S</kbd>
22. Save with ++ctrl++ + S
1. In the terminal type `python manage.py runserver`
23. In the terminal type `python manage.py runserver`
![runserver](img/day1/runserver.gif)
1. In your browser navigate to <http://localhost:8000>
24. In your browser navigate to <http://localhost:8000>
![hello](img/day1/hello.gif)
You've now passed python data to a browser! We'll explore what this really means in Day 2.
You've now passed python data to a browser! We'll explore what this really means in Day 2.