add code fence support and fix a ton of lint issues
This commit is contained in:
87
docs/day1.md
87
docs/day1.md
@@ -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
|
||||
|
||||

|
||||
|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
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!)`
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
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():`
|
||||
|
||||

|
||||
|
||||
1. Indent `print('hello, world!')` by pressing <kbd>tab</kbd>
|
||||
10. Indent `print('hello, world!')` by pressing ++tab++
|
||||
|
||||

|
||||
|
||||
1. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
|
||||
11. Give 'goodbye' the same treatment. This time type `def print_goodbye():`
|
||||
|
||||

|
||||
|
||||
1. Finally add `def middle_stuff():` above the remaining cod
|
||||
12. Finally add `def middle_stuff():` above the remaining cod
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
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!
|
||||
|
||||

|
||||
|
||||
@@ -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`
|
||||
|
||||

|
||||
|
||||
1. Expand the `config` folder by clicking on it
|
||||
3. Expand the `config` folder by clicking on it
|
||||
|
||||

|
||||
|
||||
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'`
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
1. On line 17 add `, include` after `from django.urls import path`
|
||||
8. On line 17 add `, include` after `from django.urls import path`
|
||||
|
||||

|
||||
|
||||
1. Add `path('', include('mysite.urls')),` above `path('admin/', admin.site.urls),`
|
||||
9. Add `path('', include('mysite.urls')),` above `path('admin/', admin.site.urls),`
|
||||
|
||||

|
||||
|
||||
1. Expand the newly created `mysite` folder by clicking on it
|
||||
10. Expand the newly created `mysite` folder by clicking on it
|
||||
|
||||

|
||||
|
||||
1. Right click on `mysite` and click "New Folder". Name it `templates`
|
||||
11. Right click on `mysite` and click "New Folder". Name it `templates`
|
||||
|
||||

|
||||
|
||||
1. Right click on `templates` and click "New Folder". Name it `mysite`
|
||||
12. Right click on `templates` and click "New Folder". Name it `mysite`
|
||||
|
||||

|
||||
|
||||
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`
|
||||
|
||||

|
||||
|
||||
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>
|
||||
```
|
||||
|
||||

|
||||
|
||||
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"}
|
||||
)
|
||||
```
|
||||
|
||||

|
||||
|
||||
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`
|
||||
|
||||

|
||||
|
||||
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
|
||||
|
||||

|
||||
|
||||
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`
|
||||
|
||||

|
||||
|
||||
1. In your browser navigate to <http://localhost:8000>
|
||||
24. In your browser navigate to <http://localhost:8000>
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user