├── README.md
├── git-cheat-sheet-education.pdf
├── lecture0
├── cat.jpg
├── form.html
├── image0.html
├── image1.html
├── index.html
├── lists.html
├── style0.html
└── table.html
├── lecture1
├── atributte.html
├── hover.html
├── index.html
└── multiple.html
├── lecture2
├── __pycache__
│ └── application.cpython-37.pyc
├── application.py
└── templates
│ ├── index.html
│ └── layout.html
├── lecture3
└── create.sql
├── lecture4
├── airline1
│ ├── application.py
│ └── templates
│ │ ├── error.html
│ │ ├── flight.html
│ │ ├── flights.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── success.html
├── airline2
│ ├── __pycache__
│ │ ├── application.cpython-37.pyc
│ │ └── models.cpython-37.pyc
│ ├── application.py
│ ├── models.py
│ └── templates
│ │ ├── error.html
│ │ ├── flight.html
│ │ ├── flights.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── success.html
├── airline3
│ ├── application.py
│ ├── models.py
│ └── templates
│ │ ├── error.html
│ │ ├── flight.html
│ │ ├── flights.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── success.html
├── airline4
│ ├── application.py
│ ├── models.py
│ └── templates
│ │ ├── error.html
│ │ ├── flight.html
│ │ ├── flights.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── success.html
├── airline5
│ ├── application.py
│ ├── models.py
│ └── templates
│ │ ├── error.html
│ │ ├── flight.html
│ │ ├── flights.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ └── success.html
├── classes0.py
├── classes1.py
├── classes2.py
├── classes3.py
├── classes4.py
├── classes5.py
├── create.py
├── currency0.py
├── currency1.py
├── currency2.py
├── env.sh
├── flights.csv
├── google.py
├── import0.py
├── import1.py
├── list0.py
├── list1.py
├── models.py
├── passengers0.py
└── passengers1.py
├── lecture5
├── colors0.html
├── colors1.html
├── colors2.html
├── colors3.html
├── counter0.html
├── counter1.html
├── counter2.html
├── counter3.html
├── counter3.js
├── currency
│ ├── application.py
│ ├── static
│ │ └── index.js
│ └── templates
│ │ └── index.html
├── events.html
├── hello0.html
├── hello1.html
├── interval.html
├── query.html
├── slide.pdf
├── storage.html
├── tasks0.html
├── tasks1.html
├── tasks2.html
├── variables0.html
├── variables1.html
├── variables2.html
├── vote0
│ ├── application.py
│ ├── static
│ │ └── index.js
│ └── templates
│ │ └── index.html
└── vote1
│ ├── __pycache__
│ └── application.cpython-37.pyc
│ ├── application.py
│ ├── static
│ └── index.js
│ └── templates
│ ├── index.html
│ └── index1.html
├── lecture6
├── animate0.html
├── animate1.html
├── animate2.html
├── animate3.html
├── circle0.html
├── circle1.html
├── circle2.html
├── circle3.html
├── dice0
│ └── dice.html
├── dice1
│ ├── dice.html
│ └── img
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ ├── 4.png
│ │ ├── 5.png
│ │ └── 6.png
├── dice2
│ ├── dice.html
│ └── img
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ ├── 4.png
│ │ ├── 5.png
│ │ └── 6.png
├── dice3
│ ├── dice.html
│ └── img
│ │ ├── 1.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ ├── 4.png
│ │ ├── 5.png
│ │ └── 6.png
├── draw0.html
├── draw1.html
├── draw2.html
├── draw2.js
├── multipage
│ ├── application.py
│ └── templates
│ │ ├── first.html
│ │ ├── layout.html
│ │ ├── second.html
│ │ └── third.html
├── posts0
│ ├── __pycache__
│ │ └── application.cpython-37.pyc
│ ├── application.py
│ └── templates
│ │ └── index.html
├── posts1
│ ├── application.py
│ └── templates
│ │ └── index.html
├── posts2
│ ├── application.py
│ └── templates
│ │ └── index.html
├── posts3
│ ├── application.py
│ └── templates
│ │ └── index.html
├── posts4
│ ├── __pycache__
│ │ └── application.cpython-37.pyc
│ ├── application.py
│ └── templates
│ │ └── index.html
├── rect.html
├── scroll.html
├── singlepage0
│ ├── application.py
│ └── templates
│ │ └── index.html
├── singlepage1
│ ├── application.py
│ └── templates
│ │ └── index.html
├── singlepage2
│ ├── application.py
│ └── templates
│ │ └── index.html
└── stoplight.html
├── lecture7
├── airline
│ ├── airline
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── flights
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ └── manage.py
├── authentication
│ ├── authentication
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── settings.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── wsgi.cpython-37.pyc
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── manage.py
│ └── users
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ ├── admin.cpython-37.pyc
│ │ ├── apps.cpython-37.pyc
│ │ ├── models.cpython-37.pyc
│ │ ├── urls.cpython-37.pyc
│ │ └── views.cpython-37.pyc
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ ├── __init__.py
│ │ └── __pycache__
│ │ │ └── __init__.cpython-37.pyc
│ │ ├── models.py
│ │ ├── templates
│ │ └── users
│ │ │ ├── base.html
│ │ │ ├── login.html
│ │ │ └── user.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
└── mysite
│ ├── db.sqlite3
│ ├── hello
│ ├── __init__.py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
│ ├── manage.py
│ └── mysite
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── lecture8
├── __pycache__
│ └── prime.cpython-37.pyc
├── airline0
│ ├── airline
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── settings.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── wsgi.cpython-37.pyc
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── flights
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── admin.cpython-37.pyc
│ │ │ ├── apps.cpython-37.pyc
│ │ │ ├── models.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── views.cpython-37.pyc
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ ├── __init__.py
│ │ │ └── __pycache__
│ │ │ │ ├── 0001_initial.cpython-37.pyc
│ │ │ │ ├── 0002_auto_20180325_0425.cpython-37.pyc
│ │ │ │ ├── 0003_passenger.cpython-37.pyc
│ │ │ │ └── __init__.cpython-37.pyc
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ └── manage.py
├── airline1
│ ├── airline
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── settings.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── wsgi.cpython-37.pyc
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── flights
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── admin.cpython-37.pyc
│ │ │ ├── apps.cpython-37.pyc
│ │ │ ├── models.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── views.cpython-37.pyc
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ ├── __init__.py
│ │ │ └── __pycache__
│ │ │ │ ├── 0001_initial.cpython-37.pyc
│ │ │ │ ├── 0002_auto_20180325_0425.cpython-37.pyc
│ │ │ │ ├── 0003_passenger.cpython-37.pyc
│ │ │ │ └── __init__.cpython-37.pyc
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ ├── manage.py
│ └── old.sqlite3
├── airline2
│ ├── airline
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── flights
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ └── manage.py
├── airline3
│ ├── .travis.yml
│ ├── airline
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── flights
│ │ ├── __init__.py
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ ├── manage.py
│ └── requirements.txt
├── airline4
│ ├── Dockerfile
│ ├── airline
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── settings.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── wsgi.cpython-37.pyc
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── db.sqlite3
│ ├── docker-compose.yml
│ ├── flights
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-37.pyc
│ │ │ ├── admin.cpython-37.pyc
│ │ │ ├── apps.cpython-37.pyc
│ │ │ ├── models.cpython-37.pyc
│ │ │ ├── urls.cpython-37.pyc
│ │ │ └── views.cpython-37.pyc
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20180325_0425.py
│ │ │ ├── 0003_passenger.py
│ │ │ ├── __init__.py
│ │ │ └── __pycache__
│ │ │ │ ├── 0001_initial.cpython-37.pyc
│ │ │ │ ├── 0002_auto_20180325_0425.cpython-37.pyc
│ │ │ │ ├── 0003_passenger.cpython-37.pyc
│ │ │ │ └── __init__.cpython-37.pyc
│ │ ├── models.py
│ │ ├── static
│ │ │ └── flights
│ │ │ │ └── styles.css
│ │ ├── templates
│ │ │ └── flights
│ │ │ │ ├── base.html
│ │ │ │ ├── error.html
│ │ │ │ ├── flight.html
│ │ │ │ └── index.html
│ │ ├── tests.py
│ │ ├── urls.py
│ │ └── views.py
│ ├── manage.py
│ └── requirements.txt
├── assert0.py
├── assert1.py
├── prime.py
├── selenium
│ ├── __pycache__
│ │ └── tests.cpython-37.pyc
│ ├── counter.html
│ └── tests.py
├── tests0.py
├── tests0.sh
└── tests1.py
├── project1
├── .gitignore
├── README.md
├── __pycache__
│ ├── application.cpython-37.pyc
│ └── classes.cpython-37.pyc
├── application.py
├── books.csv
├── classes.py
├── css
│ └── style.css
├── flask_session
│ ├── 2029240f6d1128be89ddc32729463129
│ ├── 6f8e1b61c9276718b4b8cb6b5c7ee9f4
│ └── de07fbaca02d27362baf6b21f8229296
├── import.py
├── requirements.txt
└── templates
│ ├── books.html
│ ├── details.html
│ ├── error.html
│ ├── index.html
│ ├── layout.html
│ ├── login.html
│ ├── register.html
│ ├── review.html
│ └── search.html
├── project2
├── README.md
├── __pycache__
│ ├── application.cpython-37.pyc
│ ├── classes.cpython-37.pyc
│ └── models.cpython-37.pyc
├── application.py
├── create.py
├── flask_session
│ ├── 04e8a9453479b242a24b9f0de44880fa
│ ├── 2029240f6d1128be89ddc32729463129
│ ├── 361259bbe02ac35864935a289a4f2e8c
│ ├── 382c2d77d5445403be7172ed57bb0a5e
│ ├── 46a37335276b11cd931a6961fbbb5332
│ ├── 85fe581e5ee1d1de0b0cf6bfb79b4661
│ ├── c2812e98b565014cd16ea68651cba8c3
│ ├── de07fbaca02d27362baf6b21f8229296
│ ├── ed7fed788b661e92b67c97a5d6978070
│ ├── f564898882840fceb98756b965d6ce94
│ └── fbdb6d9a667a7ebaa26f918437f11898
├── models.py
├── requirements.txt
├── static
│ ├── channel.js
│ ├── messages.js
│ ├── othersChannels.js
│ └── subscribe.js
└── templates
│ ├── error.html
│ ├── index.html
│ ├── layout.html
│ ├── login.html
│ ├── messages.html
│ ├── my_channels.html
│ ├── others_channels.html
│ └── register.html
└── project3
├── Procfile
├── README.md
├── db.sqlite3
├── manage.py
├── orders
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── admin.cpython-37.pyc
│ ├── apps.cpython-37.pyc
│ ├── models.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── views.cpython-37.pyc
├── admin.py
├── apps.py
├── migrations
│ ├── 0001_initial.py
│ ├── 0002_auto_20181117_2215.py
│ ├── 0003_auto_20181117_2321.py
│ ├── 0004_auto_20181117_2339.py
│ ├── 0005_auto_20181118_0249.py
│ ├── 0006_auto_20181120_1512.py
│ ├── 0007_sizeofpizza_typeofpizza.py
│ ├── 0008_remove_pizza_typeofpizza.py
│ ├── 0009_pizza_description.py
│ ├── 0010_auto_20181120_1825.py
│ ├── 0011_auto_20181120_1830.py
│ ├── 0012_auto_20181130_1847.py
│ ├── 0013_order_user.py
│ ├── 0014_auto_20181130_2307.py
│ ├── 0015_auto_20181201_0154.py
│ ├── 0016_auto_20181201_0204.py
│ ├── __init__.py
│ └── __pycache__
│ │ ├── 0001_initial.cpython-37.pyc
│ │ ├── 0002_auto_20181117_2215.cpython-37.pyc
│ │ ├── 0003_auto_20181117_2321.cpython-37.pyc
│ │ ├── 0004_auto_20181117_2339.cpython-37.pyc
│ │ ├── 0005_auto_20181118_0249.cpython-37.pyc
│ │ ├── 0006_auto_20181120_1512.cpython-37.pyc
│ │ ├── 0007_sizeofpizza_typeofpizza.cpython-37.pyc
│ │ ├── 0008_remove_pizza_typeofpizza.cpython-37.pyc
│ │ ├── 0009_pizza_description.cpython-37.pyc
│ │ ├── 0010_auto_20181120_1825.cpython-37.pyc
│ │ ├── 0011_auto_20181120_1830.cpython-37.pyc
│ │ ├── 0012_auto_20181130_1847.cpython-37.pyc
│ │ ├── 0013_order_user.cpython-37.pyc
│ │ ├── 0014_auto_20181130_2307.cpython-37.pyc
│ │ ├── 0015_auto_20181201_0154.cpython-37.pyc
│ │ ├── 0016_auto_20181201_0204.cpython-37.pyc
│ │ └── __init__.cpython-37.pyc
├── models.py
├── static
│ └── orders
│ │ ├── css
│ │ ├── fonts
│ │ │ ├── icomoon.eot
│ │ │ ├── icomoon.svg
│ │ │ ├── icomoon.ttf
│ │ │ └── icomoon.woff
│ │ └── styles.css
│ │ ├── fonts
│ │ └── icomoon.zip
│ │ ├── img
│ │ ├── rest-bg.jpg
│ │ └── rest.png
│ │ └── js
│ │ ├── cart.js
│ │ └── index.js
├── templates
│ └── orders
│ │ ├── cart.html
│ │ ├── index.html
│ │ ├── layout.html
│ │ ├── login.html
│ │ ├── orders.html
│ │ └── register.html
├── templatetags
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-37.pyc
│ │ └── helpers.cpython-37.pyc
│ └── helpers.py
├── tests.py
├── urls.py
└── views.py
├── pizza
├── __init__.py
├── __pycache__
│ ├── __init__.cpython-37.pyc
│ ├── settings.cpython-37.pyc
│ ├── urls.cpython-37.pyc
│ └── wsgi.cpython-37.pyc
├── settings.py
├── urls.py
└── wsgi.py
├── requirements.txt
└── runtime.txt
/README.md:
--------------------------------------------------------------------------------
1 | # CS50-Web-Programming-with-Python
2 |
--------------------------------------------------------------------------------
/git-cheat-sheet-education.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/git-cheat-sheet-education.pdf
--------------------------------------------------------------------------------
/lecture0/cat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture0/cat.jpg
--------------------------------------------------------------------------------
/lecture0/form.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ")
10 | def hello(name):
11 | name = name.capitalize()
12 | return f"Hello, {name}! "
13 |
--------------------------------------------------------------------------------
/lecture2/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Index
5 | {% endblock %}
6 |
7 | {% block body %}
8 |
9 | Index.html
10 |
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture2/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %} {% endblock %}
5 |
6 |
7 | Hello World
8 | {% block body %} {% endblock %}
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture3/create.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE flights (
2 | id SERIAL PRIMARY KEY,
3 | origin VARCHAR NOT NULL,
4 | destination VARCHAR NOT NULL,
5 | duration INTEGER NOT NULL
6 | );
--------------------------------------------------------------------------------
/lecture4/airline1/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 | {{ message }}
10 | {% endblock %}
11 |
--------------------------------------------------------------------------------
/lecture4/airline1/templates/flight.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flight
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flight Details
9 |
10 |
11 | Origin: {{ flight.origin }}
12 | Destination: {{ flight.destination }}
13 | Duration: {{ flight.duration}} minutes
14 |
15 |
16 | Passengers
17 |
18 | {% for passenger in passengers %}
19 | {{ passenger.name }}
20 | {% else %}
21 | No passengers.
22 | {% endfor %}
23 |
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/lecture4/airline1/templates/flights.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | All Flights
9 |
10 |
19 |
20 | {% endblock %}
21 |
--------------------------------------------------------------------------------
/lecture4/airline1/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Book a Flight
9 |
10 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/lecture4/airline1/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %}{% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture4/airline1/templates/success.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Success!
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Success!
9 |
10 | You have successfully booked your flight.
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture4/airline2/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture4/airline2/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture4/airline2/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture4/airline2/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture4/airline2/models.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask
4 | from flask_sqlalchemy import SQLAlchemy
5 |
6 | db = SQLAlchemy()
7 |
8 |
9 | class Flight(db.Model):
10 | __tablename__ = "flights"
11 | id = db.Column(db.Integer, primary_key=True)
12 | origin = db.Column(db.String, nullable=False)
13 | destination = db.Column(db.String, nullable=False)
14 | duration = db.Column(db.Integer, nullable=False)
15 |
16 |
17 | class Passenger(db.Model):
18 | __tablename__ = "passengers"
19 | id = db.Column(db.Integer, primary_key=True)
20 | name = db.Column(db.String, nullable=False)
21 | flight_id = db.Column(db.Integer, db.ForeignKey("flights.id"), nullable=False)
22 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 | {{ message }}
10 | {% endblock %}
11 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/flight.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flight
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flight Details
9 |
10 |
11 | Origin: {{ flight.origin }}
12 | Destination: {{ flight.destination }}
13 | Duration: {{ flight.duration}} minutes
14 |
15 |
16 | Passengers
17 |
18 | {% for passenger in passengers %}
19 | {{ passenger.name }}
20 | {% else %}
21 | No passengers.
22 | {% endfor %}
23 |
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/flights.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | All Flights
9 |
10 |
19 |
20 | {% endblock %}
21 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Book a Flight
9 |
10 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %}{% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture4/airline2/templates/success.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Success!
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Success!
9 |
10 | You have successfully booked your flight.
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture4/airline3/models.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask
4 | from flask_sqlalchemy import SQLAlchemy
5 |
6 | db = SQLAlchemy()
7 |
8 |
9 | class Flight(db.Model):
10 | __tablename__ = "flights"
11 | id = db.Column(db.Integer, primary_key=True)
12 | origin = db.Column(db.String, nullable=False)
13 | destination = db.Column(db.String, nullable=False)
14 | duration = db.Column(db.Integer, nullable=False)
15 |
16 | def add_passenger(self, name):
17 | p = Passenger(name=name, flight_id=self.id)
18 | db.session.add(p)
19 | db.session.commit()
20 |
21 |
22 | class Passenger(db.Model):
23 | __tablename__ = "passengers"
24 | id = db.Column(db.Integer, primary_key=True)
25 | name = db.Column(db.String, nullable=False)
26 | flight_id = db.Column(db.Integer, db.ForeignKey("flights.id"), nullable=False)
27 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 | {{ message }}
10 | {% endblock %}
11 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/flight.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flight
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flight Details
9 |
10 |
11 | Origin: {{ flight.origin }}
12 | Destination: {{ flight.destination }}
13 | Duration: {{ flight.duration}} minutes
14 |
15 |
16 | Passengers
17 |
18 | {% for passenger in passengers %}
19 | {{ passenger.name }}
20 | {% else %}
21 | No passengers.
22 | {% endfor %}
23 |
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/flights.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | All Flights
9 |
10 |
19 |
20 | {% endblock %}
21 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Book a Flight
9 |
10 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %}{% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture4/airline3/templates/success.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Success!
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Success!
9 |
10 | You have successfully booked your flight.
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture4/airline4/models.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask
4 | from flask_sqlalchemy import SQLAlchemy
5 |
6 | db = SQLAlchemy()
7 |
8 |
9 | class Flight(db.Model):
10 | __tablename__ = "flights"
11 | id = db.Column(db.Integer, primary_key=True)
12 | origin = db.Column(db.String, nullable=False)
13 | destination = db.Column(db.String, nullable=False)
14 | duration = db.Column(db.Integer, nullable=False)
15 | passengers = db.relationship("Passenger", backref="flight", lazy=True)
16 |
17 | def add_passenger(self, name):
18 | p = Passenger(name=name, flight_id=self.id)
19 | db.session.add(p)
20 | db.session.commit()
21 |
22 |
23 | class Passenger(db.Model):
24 | __tablename__ = "passengers"
25 | id = db.Column(db.Integer, primary_key=True)
26 | name = db.Column(db.String, nullable=False)
27 | flight_id = db.Column(db.Integer, db.ForeignKey("flights.id"), nullable=False)
28 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 | {{ message }}
10 | {% endblock %}
11 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/flight.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flight
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flight Details
9 |
10 |
11 | Origin: {{ flight.origin }}
12 | Destination: {{ flight.destination }}
13 | Duration: {{ flight.duration}} minutes
14 |
15 |
16 | Passengers
17 |
18 | {% for passenger in passengers %}
19 | {{ passenger.name }}
20 | {% else %}
21 | No passengers.
22 | {% endfor %}
23 |
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/flights.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | All Flights
9 |
10 |
19 |
20 | {% endblock %}
21 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Book a Flight
9 |
10 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %}{% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture4/airline4/templates/success.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Success!
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Success!
9 |
10 | You have successfully booked your flight.
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture4/airline5/models.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask
4 | from flask_sqlalchemy import SQLAlchemy
5 |
6 | db = SQLAlchemy()
7 |
8 |
9 | class Flight(db.Model):
10 | __tablename__ = "flights"
11 | id = db.Column(db.Integer, primary_key=True)
12 | origin = db.Column(db.String, nullable=False)
13 | destination = db.Column(db.String, nullable=False)
14 | duration = db.Column(db.Integer, nullable=False)
15 | passengers = db.relationship("Passenger", backref="flight", lazy=True)
16 |
17 | def add_passenger(self, name):
18 | p = Passenger(name=name, flight_id=self.id)
19 | db.session.add(p)
20 | db.session.commit()
21 |
22 |
23 | class Passenger(db.Model):
24 | __tablename__ = "passengers"
25 | id = db.Column(db.Integer, primary_key=True)
26 | name = db.Column(db.String, nullable=False)
27 | flight_id = db.Column(db.Integer, db.ForeignKey("flights.id"), nullable=False)
28 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 | {{ message }}
10 | {% endblock %}
11 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/flight.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flight
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flight Details
9 |
10 |
11 | Origin: {{ flight.origin }}
12 | Destination: {{ flight.destination }}
13 | Duration: {{ flight.duration}} minutes
14 |
15 |
16 | Passengers
17 |
18 | {% for passenger in passengers %}
19 | {{ passenger.name }}
20 | {% else %}
21 | No passengers.
22 | {% endfor %}
23 |
24 |
25 | {% endblock %}
26 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/flights.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | All Flights
9 |
10 |
19 |
20 | {% endblock %}
21 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Book a Flight
9 |
10 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %}{% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture4/airline5/templates/success.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Success!
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Success!
9 |
10 | You have successfully booked your flight.
11 | {% endblock %}
12 |
--------------------------------------------------------------------------------
/lecture4/classes0.py:
--------------------------------------------------------------------------------
1 | class Flight:
2 |
3 | def __init__(self, origin, destination, duration):
4 | self.origin = origin
5 | self.destination = destination
6 | self.duration = duration
7 |
--------------------------------------------------------------------------------
/lecture4/classes1.py:
--------------------------------------------------------------------------------
1 | class Flight:
2 |
3 | def __init__(self, origin, destination, duration):
4 | self.origin = origin
5 | self.destination = destination
6 | self.duration = duration
7 |
8 |
9 | def main():
10 |
11 | # Create flight.
12 | f = Flight(origin="New York", destination="Paris", duration=540)
13 |
14 | # Change the value of a variable.
15 | f.duration += 10
16 |
17 | # Print details about flight.
18 | print(f.origin)
19 | print(f.destination)
20 | print(f.duration)
21 |
22 | if __name__ == "__main__":
23 | main()
24 |
--------------------------------------------------------------------------------
/lecture4/classes2.py:
--------------------------------------------------------------------------------
1 | class Flight:
2 |
3 | def __init__(self, origin, destination, duration):
4 | self.origin = origin
5 | self.destination = destination
6 | self.duration = duration
7 |
8 | def print_info(self):
9 | print(f"Flight origin: {self.origin}")
10 | print(f"Flight destination: {self.destination}")
11 | print(f"Flight duration: {self.duration}")
12 |
13 |
14 | def main():
15 |
16 | f1 = Flight(origin="New York", destination="Paris", duration=540)
17 | f1.print_info()
18 |
19 | f2 = Flight(origin="Tokyo", destination="Shanghai", duration=185)
20 | f2.print_info()
21 |
22 |
23 | if __name__ == "__main__":
24 | main()
25 |
--------------------------------------------------------------------------------
/lecture4/classes3.py:
--------------------------------------------------------------------------------
1 | class Flight:
2 |
3 | def __init__(self, origin, destination, duration):
4 | self.origin = origin
5 | self.destination = destination
6 | self.duration = duration
7 |
8 | def print_info(self):
9 | print(f"Flight origin: {self.origin}")
10 | print(f"Flight destination: {self.destination}")
11 | print(f"Flight duration: {self.duration}")
12 |
13 | def delay(self, amount):
14 | self.duration += amount
15 |
16 |
17 | def main():
18 |
19 | f1 = Flight(origin="New York", destination="Paris", duration=540)
20 | f1.delay(10)
21 | f1.print_info()
22 |
23 |
24 | if __name__ == "__main__":
25 | main()
26 |
--------------------------------------------------------------------------------
/lecture4/create.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask, render_template, request
4 | from models import *
5 |
6 | app = Flask(__name__)
7 | app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
8 | app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
9 | db.init_app(app)
10 |
11 | def main():
12 | db.create_all()
13 |
14 | if __name__ == "__main__":
15 | with app.app_context():
16 | main()
17 |
--------------------------------------------------------------------------------
/lecture4/currency0.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | def main():
4 | res = requests.get("https://api.fixer.io/latest?base=USD&symbols=EUR")
5 | if res.status_code != 200:
6 | raise Exception("ERROR: API request unsuccessful.")
7 | data = res.json()
8 | print(data)
9 |
10 | if __name__ == "__main__":
11 | main()
12 |
--------------------------------------------------------------------------------
/lecture4/currency1.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | def main():
4 | res = requests.get("https://api.fixer.io/latest?base=USD&symbols=EUR")
5 | if res.status_code != 200:
6 | raise Exception("ERROR: API request unsuccessful.")
7 | data = res.json()
8 | rate = data["rates"]["EUR"]
9 | print(f"1 USD is equal to {rate} EUR")
10 |
11 | if __name__ == "__main__":
12 | main()
13 |
--------------------------------------------------------------------------------
/lecture4/currency2.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | def main():
4 | base = input("First Currency: ")
5 | other = input("Second Currency: ")
6 | res = requests.get("https://api.fixer.io/latest",
7 | params={"base": base, "symbols": other})
8 | if res.status_code != 200:
9 | raise Exception("ERROR: API request unsuccessful.")
10 | data = res.json()
11 | rate = data["rates"][other]
12 | print(f"1 {base} is equal to {rate} {other}")
13 |
14 | if __name__ == "__main__":
15 | main()
16 |
--------------------------------------------------------------------------------
/lecture4/env.sh:
--------------------------------------------------------------------------------
1 | export DATABASE_URL="postgres://localhost/lecture4"
2 |
--------------------------------------------------------------------------------
/lecture4/flights.csv:
--------------------------------------------------------------------------------
1 | Paris,New York,540
2 | Tokyo,Shanghai,185
3 | Seoul,Mexico City,825
4 | Mexico City,Lima,350
5 | Hong Kong,Shanghai,130
6 |
--------------------------------------------------------------------------------
/lecture4/google.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | def main():
4 | res = requests.get("https://www.google.com/")
5 | print(res.text)
6 |
7 | if __name__ == "__main__":
8 | main()
9 |
--------------------------------------------------------------------------------
/lecture4/import0.py:
--------------------------------------------------------------------------------
1 | import csv
2 | import os
3 |
4 | from sqlalchemy import create_engine
5 | from sqlalchemy.orm import scoped_session, sessionmaker
6 |
7 | engine = create_engine(os.getenv("DATABASE_URL"))
8 | db = scoped_session(sessionmaker(bind=engine))
9 |
10 | def main():
11 | f = open("flights.csv")
12 | reader = csv.reader(f)
13 | for origin, destination, duration in reader:
14 | db.execute("INSERT INTO flights (origin, destination, duration) VALUES (:origin, :destination, :duration)",
15 | {"origin": origin, "destination": destination, "duration": duration})
16 | print(f"Added flight from {origin} to {destination} lasting {duration} minutes.")
17 | db.commit()
18 |
19 | if __name__ == "__main__":
20 | main()
21 |
--------------------------------------------------------------------------------
/lecture4/import1.py:
--------------------------------------------------------------------------------
1 | import csv
2 | import os
3 |
4 | from flask import Flask, render_template, request
5 | from models import *
6 |
7 | app = Flask(__name__)
8 | app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
9 | app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
10 | db.init_app(app)
11 |
12 | def main():
13 | f = open("flights.csv")
14 | reader = csv.reader(f)
15 | for origin, destination, duration in reader:
16 | flight = Flight(origin=origin, destination=destination, duration=duration)
17 | db.session.add(flight)
18 | print(f"Added flight from {origin} to {destination} lasting {duration} minutes.")
19 | db.session.commit()
20 |
21 | if __name__ == "__main__":
22 | with app.app_context():
23 | main()
24 |
--------------------------------------------------------------------------------
/lecture4/list0.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from sqlalchemy import create_engine
4 | from sqlalchemy.orm import scoped_session, sessionmaker
5 |
6 | engine = create_engine(os.getenv("DATABASE_URL"))
7 | db = scoped_session(sessionmaker(bind=engine))
8 |
9 | def main():
10 | flights = db.execute("SELECT origin, destination, duration FROM flights").fetchall()
11 | for flight in flights:
12 | print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")
13 |
14 | if __name__ == "__main__":
15 | main()
16 |
--------------------------------------------------------------------------------
/lecture4/list1.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask, render_template, request
4 | from models import *
5 |
6 | app = Flask(__name__)
7 | app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
8 | app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
9 | db.init_app(app)
10 |
11 | def main():
12 | flights = Flight.query.all()
13 | for flight in flights:
14 | print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")
15 |
16 | if __name__ == "__main__":
17 | with app.app_context():
18 | main()
19 |
--------------------------------------------------------------------------------
/lecture4/models.py:
--------------------------------------------------------------------------------
1 | from flask_sqlalchemy import SQLAlchemy
2 |
3 | db = SQLAlchemy()
4 |
5 | class Flight(db.Model):
6 | __tablename__ = "flights"
7 | id = db.Column(db.Integer, primary_key=True)
8 | origin = db.Column(db.String, nullable=False)
9 | destination = db.Column(db.String, nullable=False)
10 | duration = db.Column(db.Integer, nullable=False)
11 |
12 |
13 | class Passenger(db.Model):
14 | __tablename__ = "passengers"
15 | id = db.Column(db.Integer, primary_key=True)
16 | name = db.Column(db.String, nullable=False)
17 | flight_id = db.Column(db.Integer, db.ForeignKey("flights.id"), nullable=False)
18 |
--------------------------------------------------------------------------------
/lecture5/colors1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 | My Website
18 |
19 |
20 | Hello!
21 | Red
22 | Blue
23 | Green
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lecture5/colors2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 | My Website
17 |
18 |
19 | Hello!
20 | Red
21 | Blue
22 | Green
23 |
24 |
25 |
--------------------------------------------------------------------------------
/lecture5/colors3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 | My Website
15 |
16 |
17 | Hello!
18 |
19 | Black
20 | Red
21 | Blue
22 | Green
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lecture5/counter0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 | My Website
15 |
16 |
17 | 0
18 | Click Here!
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lecture5/counter1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 | My Website
19 |
20 |
21 | 0
22 | Click Here!
23 |
24 |
25 |
--------------------------------------------------------------------------------
/lecture5/counter2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 | My Website
23 |
24 |
25 | 0
26 | Click Here!
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lecture5/counter3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | My Website
6 |
7 |
8 | 0
9 | Click Here!
10 |
11 |
12 |
--------------------------------------------------------------------------------
/lecture5/counter3.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', function() {
2 | document.querySelector('button').onclick = count;
3 | });
4 |
5 | let counter = 0;
6 |
7 | function count() {
8 | counter++;
9 | document.querySelector('#counter').innerHTML = counter;
10 |
11 | if (counter % 10 === 0) {
12 | alert(`Counter is at ${counter}!`);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lecture5/currency/application.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 |
8 | @app.route("/")
9 | def index():
10 | return render_template("index.html")
11 |
12 |
13 | @app.route("/convert", methods=["POST"])
14 | def convert():
15 |
16 | # Query for currency exchange rate
17 | currency = request.form.get("currency")
18 | res = requests.get("https://api.fixer.io/latest", params={
19 | "base": "USD", "symbols": currency})
20 |
21 | # Make sure request succeeded
22 | if res.status_code != 200:
23 | return jsonify({"success": False})
24 |
25 | # Make sure currency is in response
26 | data = res.json()
27 | if currency not in data["rates"]:
28 | return jsonify({"success": False})
29 |
30 | return jsonify({"success": True, "rate": data["rates"][currency]})
31 |
--------------------------------------------------------------------------------
/lecture5/currency/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Currency Converter
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/lecture5/events.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 | My Website
13 |
14 |
15 | Welcome!
16 | Click Here!
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture5/hello0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 | My Website
8 |
9 |
10 | Welcome!
11 |
12 |
13 |
--------------------------------------------------------------------------------
/lecture5/hello1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 | My Website
13 |
14 |
15 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/lecture5/interval.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 | My Website
19 |
20 |
21 | 0
22 |
23 |
24 |
--------------------------------------------------------------------------------
/lecture5/query.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 | My Website
13 |
14 |
15 | Welcome!
16 | Click Here!
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture5/slide.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture5/slide.pdf
--------------------------------------------------------------------------------
/lecture5/variables0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 | My Website
14 |
15 |
16 | Welcome!
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture5/variables1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
13 | My Website
14 |
15 |
16 | Welcome!
17 |
18 |
19 |
--------------------------------------------------------------------------------
/lecture5/variables2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 | My Website
13 |
14 |
15 | Welcome!
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture5/vote0/application.py:
--------------------------------------------------------------------------------
1 | import os
2 | import requests
3 |
4 | from flask import Flask, jsonify, render_template, request
5 | from flask_socketio import SocketIO, emit
6 |
7 | app = Flask(__name__)
8 | app.config["SECRET_KEY"] = os.getenv("SECRET_KEY")
9 | socketio = SocketIO(app)
10 |
11 | @app.route("/")
12 | def index():
13 | return render_template("index.html")
14 |
15 | @socketio.on("submit vote")
16 | def vote(data):
17 | selection = data["selection"]
18 | emit("announce vote", {"selection": selection}, broadcast=True)
19 |
--------------------------------------------------------------------------------
/lecture5/vote0/static/index.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', () => {
2 |
3 | // Connect to websocket
4 | var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port);
5 |
6 | // When connected, configure buttons
7 | socket.on('connect', () => {
8 |
9 | // Each button should emit a "submit vote" event
10 | document.querySelectorAll('button').forEach(button => {
11 | button.onclick = () => {
12 | const selection = button.dataset.vote;
13 | socket.emit('submit vote', {'selection': selection});
14 | };
15 | });
16 | });
17 |
18 | // When a new vote is announced, add to the unordered list
19 | socket.on('announce vote', data => {
20 | const li = document.createElement('li');
21 | li.innerHTML = `Vote recorded: ${data.selection}`;
22 | document.querySelector('#votes').append(li);
23 | });
24 | });
25 |
--------------------------------------------------------------------------------
/lecture5/vote0/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vote
7 |
8 |
9 |
11 |
12 | Yes
13 | No
14 | Maybe
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lecture5/vote1/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture5/vote1/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture5/vote1/application.py:
--------------------------------------------------------------------------------
1 | import os
2 | import requests
3 |
4 | from flask import Flask, jsonify, render_template, request
5 | from flask_socketio import SocketIO, emit
6 |
7 | app = Flask(__name__)
8 | app.config["SECRET_KEY"] = os.getenv("SECRET_KEY")
9 | socketio = SocketIO(app)
10 |
11 | votes = {"yes": 0, "no": 0, "maybe": 0}
12 |
13 |
14 | @app.route("/")
15 | def index():
16 | return render_template("index.html", votes=votes)
17 |
18 |
19 |
20 | @app.route("/index1")
21 | def index1():
22 | return render_template("index1.html", votes=votes)
23 |
24 | @socketio.on("submit vote")
25 | def vote(data):
26 | selection = data["selection"]
27 | votes[selection] += 1
28 | emit("vote totals", votes, broadcast=True)
29 |
--------------------------------------------------------------------------------
/lecture5/vote1/templates/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vote
7 |
8 |
9 | Yes Votes: {{ votes["yes"] }}
10 | No Votes: {{ votes["no"] }}
11 | Maybe Votes: {{ votes["maybe"] }}
12 |
13 | Yes
14 | No
15 | Maybe
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture5/vote1/templates/index1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vote
7 |
8 |
9 | Yes Votes: {{ votes["yes"] }}
10 | No Votes: {{ votes["no"] }}
11 | Maybe Votes: {{ votes["maybe"] }}
12 |
13 | Yes
14 | No
15 | Maybe
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lecture6/animate0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My Webpage
5 |
21 |
22 |
23 | Welcome!
24 |
25 |
26 |
--------------------------------------------------------------------------------
/lecture6/animate1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My Webpage
5 |
22 |
23 |
24 | Welcome!
25 |
26 |
27 |
--------------------------------------------------------------------------------
/lecture6/animate2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My Webpage
5 |
25 |
26 |
27 | Welcome!
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lecture6/circle0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/lecture6/circle1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
20 |
21 |
--------------------------------------------------------------------------------
/lecture6/circle2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
26 |
27 |
--------------------------------------------------------------------------------
/lecture6/circle3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
31 |
32 |
--------------------------------------------------------------------------------
/lecture6/dice1/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/1.png
--------------------------------------------------------------------------------
/lecture6/dice1/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/2.png
--------------------------------------------------------------------------------
/lecture6/dice1/img/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/3.png
--------------------------------------------------------------------------------
/lecture6/dice1/img/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/4.png
--------------------------------------------------------------------------------
/lecture6/dice1/img/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/5.png
--------------------------------------------------------------------------------
/lecture6/dice1/img/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice1/img/6.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/1.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/2.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/3.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/4.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/5.png
--------------------------------------------------------------------------------
/lecture6/dice2/img/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice2/img/6.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/1.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/2.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/3.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/4.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/5.png
--------------------------------------------------------------------------------
/lecture6/dice3/img/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/dice3/img/6.png
--------------------------------------------------------------------------------
/lecture6/draw0.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
26 |
27 |
--------------------------------------------------------------------------------
/lecture6/draw1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
38 |
39 |
--------------------------------------------------------------------------------
/lecture6/multipage/application.py:
--------------------------------------------------------------------------------
1 | from flask import Flask, render_template
2 |
3 | app = Flask(__name__)
4 |
5 | @app.route("/")
6 | def first():
7 | return render_template("first.html")
8 |
9 | @app.route("/second")
10 | def second():
11 | return render_template("second.html")
12 |
13 | @app.route("/third")
14 | def third():
15 | return render_template("third.html")
16 |
--------------------------------------------------------------------------------
/lecture6/multipage/templates/first.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block body %}
4 | First Page
5 |
6 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam tortor mauris, maximus semper volutpat vitae, varius placerat dui. Nunc consequat dictum est, at vestibulum est hendrerit at. Mauris suscipit neque ultrices nisl interdum accumsan. Sed euismod, ligula eget tristique semper, lectus est pellentesque dui, sit amet rhoncus leo mi nec orci. Curabitur hendrerit, est in ultricies interdum, lacus lacus aliquam mauris, vel vestibulum magna nisl id arcu. Cras luctus tellus ac convallis venenatis. Cras consequat tempor tincidunt. Proin ultricies purus mauris, non tempor turpis mollis id. Nam iaculis risus mauris, quis ornare neque semper vel.
7 | {% endblock %}
8 |
--------------------------------------------------------------------------------
/lecture6/multipage/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | My Webpage
5 |
6 |
7 |
12 |
13 | {% block body %}
14 | {% endblock %}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/lecture6/multipage/templates/second.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block body %}
4 | Second Page
5 |
6 | Praesent euismod auctor quam, id congue tellus malesuada vitae. Ut sed lacinia quam. Sed vitae mattis metus, vel gravida ante. Praesent tincidunt nulla non sapien tincidunt, vitae semper diam faucibus. Nulla venenatis tincidunt efficitur. Integer justo nunc, egestas eget dignissim dignissim, fermentum ac sapien. Suspendisse non libero facilisis, dictum nunc ut, tincidunt diam.
7 | {% endblock %}
8 |
--------------------------------------------------------------------------------
/lecture6/multipage/templates/third.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block body %}
4 | Third Page
5 |
6 | Morbi imperdiet nunc ac quam hendrerit faucibus. Morbi viverra justo est, ut bibendum lacus vehicula at. Fusce eget risus arcu. Quisque dictum porttitor nisl, eget condimentum leo mollis sed. Proin justo nisl, lacinia id erat in, suscipit ultrices nisi. Suspendisse placerat nulla at volutpat interdum. In porttitor condimentum est nec ultricies. Donec nec mollis neque, id dapibus sem.
7 | {% endblock %}
8 |
--------------------------------------------------------------------------------
/lecture6/posts0/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/posts0/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture6/posts0/application.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route("/")
8 | def index():
9 | return render_template("index.html")
10 |
11 | @app.route("/posts", methods=["POST"])
12 | def posts():
13 |
14 | # Get start and end point for posts to generate.
15 | start = int(request.form.get("start") or 0)
16 | end = int(request.form.get("end") or (start + 9))
17 |
18 | # Generate list of posts.
19 | data = []
20 | for i in range(start, end + 1):
21 | data.append(f"Post #{i}")
22 |
23 | # Artificially delay speed of response.
24 | time.sleep(1)
25 |
26 | # Return list of posts.
27 | return jsonify(data)
28 |
--------------------------------------------------------------------------------
/lecture6/posts1/application.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route("/")
8 | def index():
9 | return render_template("index.html")
10 |
11 | @app.route("/posts", methods=["POST"])
12 | def posts():
13 |
14 | # Get start and end point for posts to generate.
15 | start = int(request.form.get("start") or 0)
16 | end = int(request.form.get("end") or (start + 9))
17 |
18 | # Generate list of posts.
19 | data = []
20 | for i in range(start, end + 1):
21 | data.append(f"Post #{i}")
22 |
23 | # Artificially delay speed of response.
24 | time.sleep(1)
25 |
26 | # Return list of posts.
27 | return jsonify(data)
28 |
--------------------------------------------------------------------------------
/lecture6/posts2/application.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route("/")
8 | def index():
9 | return render_template("index.html")
10 |
11 | @app.route("/posts", methods=["POST"])
12 | def posts():
13 |
14 | # Get start and end point for posts to generate.
15 | start = int(request.form.get("start") or 0)
16 | end = int(request.form.get("end") or (start + 9))
17 |
18 | # Generate list of posts.
19 | data = []
20 | for i in range(start, end + 1):
21 | data.append(f"Post #{i}")
22 |
23 | # Artificially delay speed of response.
24 | time.sleep(1)
25 |
26 | # Return list of posts.
27 | return jsonify(data)
28 |
--------------------------------------------------------------------------------
/lecture6/posts3/application.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route("/")
8 | def index():
9 | return render_template("index.html")
10 |
11 | @app.route("/posts", methods=["POST"])
12 | def posts():
13 |
14 | # Get start and end point for posts to generate.
15 | start = int(request.form.get("start") or 0)
16 | end = int(request.form.get("end") or (start + 9))
17 |
18 | # Generate list of posts.
19 | data = []
20 | for i in range(start, end + 1):
21 | data.append(f"Post #{i}")
22 |
23 | # Artificially delay speed of response.
24 | time.sleep(1)
25 |
26 | # Return list of posts.
27 | return jsonify(data)
28 |
--------------------------------------------------------------------------------
/lecture6/posts4/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture6/posts4/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture6/posts4/application.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | from flask import Flask, jsonify, render_template, request
4 |
5 | app = Flask(__name__)
6 |
7 | @app.route("/")
8 | def index():
9 | return render_template("index.html")
10 |
11 | @app.route("/posts", methods=["POST"])
12 | def posts():
13 |
14 | # Get start and end point for posts to generate.
15 | start = int(request.form.get("start") or 0)
16 | end = int(request.form.get("end") or (start + 9))
17 |
18 | # Generate list of posts.
19 | data = []
20 | for i in range(start, end + 1):
21 | data.append(f"Post #{i}")
22 |
23 | # Artificially delay speed of response.
24 | time.sleep(1)
25 |
26 | # Return list of posts.
27 | return jsonify(data)
28 |
--------------------------------------------------------------------------------
/lecture6/rect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
21 |
22 |
--------------------------------------------------------------------------------
/lecture7/airline/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/airline/airline/__init__.py
--------------------------------------------------------------------------------
/lecture7/airline/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture7/airline/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture7/airline/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/airline/db.sqlite3
--------------------------------------------------------------------------------
/lecture7/airline/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/airline/flights/__init__.py
--------------------------------------------------------------------------------
/lecture7/airline/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/airline/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture7/airline/flights/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 | class Airport(models.Model):
5 | code = models.CharField(max_length=3)
6 | city = models.CharField(max_length=64)
7 |
8 | def __str__(self):
9 | return f"{self.city} ({self.code})"
10 |
11 | class Flight(models.Model):
12 | origin = models.ForeignKey(Airport, on_delete=models.CASCADE, related_name="departures")
13 | destination = models.ForeignKey(Airport, on_delete=models.CASCADE, related_name="arrivals")
14 | duration = models.IntegerField()
15 |
16 | def __str__(self):
17 | return f"{self.id} - {self.origin} to {self.destination}"
18 |
19 | class Passenger(models.Model):
20 | first = models.CharField(max_length=64)
21 | last = models.CharField(max_length=64)
22 | flights = models.ManyToManyField(Flight, blank=True, related_name="passengers")
23 |
24 | def __str__(self):
25 | return f"{self.first} {self.last}"
26 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture7/airline/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture7/airline/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/authentication/__init__.py
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/authentication/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/authentication/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/authentication/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/authentication/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/urls.py:
--------------------------------------------------------------------------------
1 | """authentication URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path("", include("users.urls")),
21 | path("admin/", admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture7/authentication/authentication/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for authentication project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authentication.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture7/authentication/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/db.sqlite3
--------------------------------------------------------------------------------
/lecture7/authentication/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authentication.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__init__.py
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class UsersConfig(AppConfig):
5 | name = 'users'
6 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture7/authentication/users/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/authentication/users/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture7/authentication/users/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/templates/users/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Users
5 |
6 |
7 | {% block body %}
8 | {% endblock %}
9 |
10 |
11 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/templates/users/login.html:
--------------------------------------------------------------------------------
1 | {% extends "users/base.html" %}
2 |
3 | {% block body %}
4 | Login
5 | {% if message %}
6 |
7 | {{ message }}
8 |
9 | {% endif %}
10 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/templates/users/user.html:
--------------------------------------------------------------------------------
1 | {% extends "users/base.html" %}
2 |
3 | {% block body %}
4 | Hello, {{ user.first_name }}
5 |
6 | Currently logged in as: {{ user.username }}
7 | Logout
8 |
9 | {% endblock %}
10 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture7/authentication/users/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("login", views.login_view, name="login"),
8 | path("logout", views.logout_view, name="logout")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture7/mysite/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/mysite/db.sqlite3
--------------------------------------------------------------------------------
/lecture7/mysite/hello/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/mysite/hello/__init__.py
--------------------------------------------------------------------------------
/lecture7/mysite/hello/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | # Register your models here.
4 |
--------------------------------------------------------------------------------
/lecture7/mysite/hello/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class HelloConfig(AppConfig):
5 | name = 'hello'
6 |
--------------------------------------------------------------------------------
/lecture7/mysite/hello/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/mysite/hello/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture7/mysite/hello/models.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 |
3 | # Create your models here.
4 |
--------------------------------------------------------------------------------
/lecture7/mysite/hello/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture7/mysite/hello/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index),
7 | path("second", views.second)
8 | ]
9 |
--------------------------------------------------------------------------------
/lecture7/mysite/hello/views.py:
--------------------------------------------------------------------------------
1 | from django.http import HttpResponse
2 | from django.shortcuts import render
3 |
4 | # Create your views here.
5 | def index(request):
6 | return HttpResponse("Hello, world!")
7 |
8 | def second(request):
9 | return HttpResponse("Second page")
10 |
--------------------------------------------------------------------------------
/lecture7/mysite/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture7/mysite/mysite/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture7/mysite/mysite/__init__.py
--------------------------------------------------------------------------------
/lecture7/mysite/mysite/urls.py:
--------------------------------------------------------------------------------
1 | """mysite URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path("", include("hello.urls")),
21 | path("admin/", admin.site.urls)
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture7/mysite/mysite/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for mysite project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/__pycache__/prime.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/__pycache__/prime.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/airline/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline0/airline/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/airline/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/airline/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/airline/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/airline/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/airline/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/airline/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/airline/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline0/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/airline0/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/db.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline0/flights/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline0/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/lecture8/airline0/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture8/airline0/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture8/airline1/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/airline/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline1/airline/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/airline/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/airline/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/airline/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/airline/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/airline/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/airline/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/airline/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline1/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/airline1/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/db.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/flights/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline1/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture8/airline1/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture8/airline1/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture8/airline1/old.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline1/old.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline2/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline2/airline/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline2/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline2/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/airline2/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline2/db.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline2/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline2/flights/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline2/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline2/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline2/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture8/airline2/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture8/airline2/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture8/airline3/.travis.yml:
--------------------------------------------------------------------------------
1 | language: python
2 | python:
3 | - 3.6
4 | install:
5 | - pip install -r requirements.txt
6 | script:
7 | - python manage.py test
8 |
--------------------------------------------------------------------------------
/lecture8/airline3/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline3/airline/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline3/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline3/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/airline3/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline3/db.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline3/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline3/flights/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline3/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline3/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline3/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture8/airline3/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture8/airline3/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture8/airline3/requirements.txt:
--------------------------------------------------------------------------------
1 | Django==2.0
2 |
--------------------------------------------------------------------------------
/lecture8/airline4/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3
2 | WORKDIR /usr/src/app
3 | ADD requirements.txt /usr/src/app
4 | RUN pip install -r requirements.txt
5 | ADD . /usr/src/app
6 |
--------------------------------------------------------------------------------
/lecture8/airline4/airline/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/airline/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline4/airline/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/airline/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/airline/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/airline/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/airline/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/airline/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/airline/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/airline/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/airline/urls.py:
--------------------------------------------------------------------------------
1 | """airline URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path('', include('flights.urls')),
21 | path('admin/', admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline4/airline/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for airline project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/lecture8/airline4/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/db.sqlite3
--------------------------------------------------------------------------------
/lecture8/airline4/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | db:
5 | image: postgres
6 | migration:
7 | build: .
8 | command: python3 manage.py migrate
9 | volumes:
10 | - .:/usr/src/app
11 | depends_on:
12 | - db
13 | web:
14 | build: .
15 | command: python3 manage.py runserver 0.0.0.0:8000
16 | volumes:
17 | - .:/usr/src/app
18 | ports:
19 | - "8000:8000"
20 | depends_on:
21 | - db
22 | - migration
23 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import Airport, Flight, Passenger
4 |
5 | # Register your models here.
6 |
7 | class PassengerInline(admin.StackedInline):
8 | model = Passenger.flights.through
9 | extra = 1
10 |
11 | class FlightAdmin(admin.ModelAdmin):
12 | inlines = [PassengerInline]
13 |
14 | class PassengerAdmin(admin.ModelAdmin):
15 | filter_horizontal = ("flights",)
16 |
17 | admin.site.register(Airport)
18 | admin.site.register(Flight, FlightAdmin)
19 | admin.site.register(Passenger, PassengerAdmin)
20 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class FlightsConfig(AppConfig):
5 | name = 'flights'
6 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:14
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Flight',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('origin', models.CharField(max_length=64)),
19 | ('destination', models.CharField(max_length=64)),
20 | ('duration', models.IntegerField()),
21 | ],
22 | ),
23 | ]
24 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/0003_passenger.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0 on 2018-03-25 04:54
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('flights', '0002_auto_20180325_0425'),
10 | ]
11 |
12 | operations = [
13 | migrations.CreateModel(
14 | name='Passenger',
15 | fields=[
16 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
17 | ('first', models.CharField(max_length=64)),
18 | ('last', models.CharField(max_length=64)),
19 | ('flights', models.ManyToManyField(to='flights.Flight')),
20 | ],
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/migrations/__init__.py
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/migrations/__pycache__/0002_auto_20180325_0425.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/migrations/__pycache__/0003_passenger.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/airline4/flights/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/airline4/flights/static/flights/styles.css:
--------------------------------------------------------------------------------
1 | body {
2 | font-family: sans-serif;
3 | }
4 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/templates/flights/base.html:
--------------------------------------------------------------------------------
1 | {% load static %}
2 |
3 |
4 |
5 |
6 | {% block title %}{% endblock %}
7 |
8 |
9 |
10 | {% block body %}
11 | {% endblock %}
12 |
13 |
14 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/templates/flights/error.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 | {{ message }}
11 |
12 |
13 |
14 | Return to flights.
15 |
16 | {% endblock %}
17 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/templates/flights/index.html:
--------------------------------------------------------------------------------
1 | {% extends "flights/base.html" %}
2 |
3 | {% block title %}
4 | Flights
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Flights
9 |
10 | {% for flight in flights %}
11 |
12 |
13 | Flight #{{ flight.id }}: {{ flight.origin }} to {{ flight.destination }}
14 |
15 |
16 | {% endfor %}
17 | {% endblock %}
18 |
--------------------------------------------------------------------------------
/lecture8/airline4/flights/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("", views.flight, name="flight"),
8 | path("/book", views.book, name="book")
9 | ]
10 |
--------------------------------------------------------------------------------
/lecture8/airline4/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "airline.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/lecture8/airline4/requirements.txt:
--------------------------------------------------------------------------------
1 | Django==2.0
2 | psycopg2
3 |
--------------------------------------------------------------------------------
/lecture8/assert0.py:
--------------------------------------------------------------------------------
1 | def square(x):
2 | return x * x
3 |
4 | assert square(10) == 100
5 |
--------------------------------------------------------------------------------
/lecture8/assert1.py:
--------------------------------------------------------------------------------
1 | def square(x):
2 | return x * x
3 |
4 | assert square(10) == 101
5 |
--------------------------------------------------------------------------------
/lecture8/prime.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | def is_prime(n):
4 | """Determines if a non-negative integer is prime."""
5 | if n < 2:
6 | return False
7 | for i in range(2, int(math.sqrt(n)) + 1):
8 | if n % i == 0:
9 | return False
10 | return True
11 |
--------------------------------------------------------------------------------
/lecture8/selenium/__pycache__/tests.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/lecture8/selenium/__pycache__/tests.cpython-37.pyc
--------------------------------------------------------------------------------
/lecture8/selenium/counter.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Counter
5 |
22 |
23 |
24 | 0
25 | +
26 | -
27 |
28 |
29 |
--------------------------------------------------------------------------------
/lecture8/tests0.py:
--------------------------------------------------------------------------------
1 | from prime import is_prime
2 |
3 |
4 | def test_prime(n, expected):
5 | if is_prime(n) != expected:
6 | print(f"ERROR on is_prime({n}), expected {expected}")
7 |
--------------------------------------------------------------------------------
/lecture8/tests0.sh:
--------------------------------------------------------------------------------
1 | python3 -c "from tests0 import test_prime; test_prime(1, False)"
2 | python3 -c "from tests0 import test_prime; test_prime(2, True)"
3 | python3 -c "from tests0 import test_prime; test_prime(8, False)"
4 | python3 -c "from tests0 import test_prime; test_prime(11, True)"
5 | python3 -c "from tests0 import test_prime; test_prime(25, False)"
6 | python3 -c "from tests0 import test_prime; test_prime(28, False)"
7 |
--------------------------------------------------------------------------------
/lecture8/tests1.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | from prime import is_prime
4 |
5 |
6 | class Tests(unittest.TestCase):
7 |
8 | def test_1(self):
9 | """Check that 1 is not prime."""
10 | self.assertFalse(is_prime(1))
11 |
12 | def test_2(self):
13 | """Check that 2 is prime."""
14 | self.assertTrue(is_prime(2))
15 |
16 | def test_8(self):
17 | """Check that 8 is not prime."""
18 | self.assertFalse(is_prime(8))
19 |
20 | def test_11(self):
21 | """Check that 11 is prime."""
22 | self.assertTrue(is_prime(11))
23 |
24 | def test_25(self):
25 | """Check that 25 is not prime."""
26 | self.assertFalse(is_prime(25))
27 |
28 | def test_28(self):
29 | """Check that 28 is not prime."""
30 | self.assertFalse(is_prime(28))
31 |
32 |
33 | if __name__ == "__main__":
34 | unittest.main()
35 |
--------------------------------------------------------------------------------
/project1/README.md:
--------------------------------------------------------------------------------
1 | # Project 1
2 |
3 | Web Programming with Python and JavaScript
4 |
--------------------------------------------------------------------------------
/project1/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project1/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/project1/__pycache__/classes.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project1/__pycache__/classes.cpython-37.pyc
--------------------------------------------------------------------------------
/project1/classes.py:
--------------------------------------------------------------------------------
1 | class User:
2 | def __init__(self, id=0, name="", email="", username="", password=""):
3 | self.id = id
4 | self.name = name
5 | self.email = email
6 | self.username = username
7 | self.password = password
8 |
9 | class Book:
10 | def __init__(self, id=0, isbn="", title="", author="", year="", reviews_count=0, average_rating=0.0):
11 | self.id = id
12 | self.isbn = isbn
13 | self.title = title
14 | self.author = author
15 | self.year = year
16 | self.reviews_count = reviews_count
17 | self.average_rating = average_rating
--------------------------------------------------------------------------------
/project1/css/style.css:
--------------------------------------------------------------------------------
1 | .page-title {
2 | text-align: center;
3 | }
--------------------------------------------------------------------------------
/project1/flask_session/2029240f6d1128be89ddc32729463129:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project1/flask_session/2029240f6d1128be89ddc32729463129
--------------------------------------------------------------------------------
/project1/flask_session/6f8e1b61c9276718b4b8cb6b5c7ee9f4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project1/flask_session/6f8e1b61c9276718b4b8cb6b5c7ee9f4
--------------------------------------------------------------------------------
/project1/flask_session/de07fbaca02d27362baf6b21f8229296:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project1/flask_session/de07fbaca02d27362baf6b21f8229296
--------------------------------------------------------------------------------
/project1/import.py:
--------------------------------------------------------------------------------
1 | import csv, os
2 | from sqlalchemy import create_engine
3 | from sqlalchemy.orm import scoped_session, sessionmaker
4 |
5 |
6 | # Check for environment variable
7 | if not os.getenv("DATABASE_URL"):
8 | raise RuntimeError("DATABASE_URL is not set")
9 |
10 | # Set up database
11 | engine = create_engine(os.getenv("DATABASE_URL"))
12 | db = scoped_session(sessionmaker(bind=engine))
13 |
14 | def main():
15 | f = open("books.csv")
16 | print(type(f))
17 | reader = csv.reader(f)
18 | print(type(reader))
19 | for isbn, title, author, year in reader[1:]:
20 | db.execute("INSERT INTO books(isbn, title, author, year) VALUES (:isbn, :title, :author, :year)", {"isbn": isbn, "title": title, "author": author, "year": year})
21 | db.commit()
22 |
23 | if __name__ == "__main__":
24 | main()
--------------------------------------------------------------------------------
/project1/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask
2 | Flask-Session
3 | psycopg2
4 | SQLAlchemy
5 |
--------------------------------------------------------------------------------
/project1/templates/details.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Details
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Details - {{book.title}}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
27 |
28 |
29 | {% endblock %}
--------------------------------------------------------------------------------
/project1/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Index
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 |
11 |
{{ message }}
12 |
13 |
14 |
17 | {% endblock %}
--------------------------------------------------------------------------------
/project1/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Index
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Index
9 |
10 |
13 |
14 |
17 |
18 | {% endblock %}
--------------------------------------------------------------------------------
/project1/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %} {% endblock %}
5 |
6 |
7 |
8 |
9 | {% block body %}
10 | {% endblock %}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/project1/templates/login.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Index
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Login
9 |
21 |
22 |
25 | {% endblock %}
--------------------------------------------------------------------------------
/project1/templates/search.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Search
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Search
9 |
10 |
18 |
19 |
22 |
23 | {% endblock %}
--------------------------------------------------------------------------------
/project2/README.md:
--------------------------------------------------------------------------------
1 | # Project 2
2 |
3 | Web Programming with Python and JavaScript
4 |
--------------------------------------------------------------------------------
/project2/__pycache__/application.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/__pycache__/application.cpython-37.pyc
--------------------------------------------------------------------------------
/project2/__pycache__/classes.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/__pycache__/classes.cpython-37.pyc
--------------------------------------------------------------------------------
/project2/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/project2/create.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from flask import Flask, render_template, request
4 | from models import *
5 |
6 | app = Flask(__name__)
7 | app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("DATABASE_URL")
8 | app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
9 | db.init_app(app)
10 |
11 | def main():
12 | db.create_all()
13 |
14 | if __name__ == "__main__":
15 | with app.app_context():
16 | main()
17 |
--------------------------------------------------------------------------------
/project2/flask_session/04e8a9453479b242a24b9f0de44880fa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/04e8a9453479b242a24b9f0de44880fa
--------------------------------------------------------------------------------
/project2/flask_session/2029240f6d1128be89ddc32729463129:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/2029240f6d1128be89ddc32729463129
--------------------------------------------------------------------------------
/project2/flask_session/361259bbe02ac35864935a289a4f2e8c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/361259bbe02ac35864935a289a4f2e8c
--------------------------------------------------------------------------------
/project2/flask_session/382c2d77d5445403be7172ed57bb0a5e:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/382c2d77d5445403be7172ed57bb0a5e
--------------------------------------------------------------------------------
/project2/flask_session/46a37335276b11cd931a6961fbbb5332:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/46a37335276b11cd931a6961fbbb5332
--------------------------------------------------------------------------------
/project2/flask_session/85fe581e5ee1d1de0b0cf6bfb79b4661:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/85fe581e5ee1d1de0b0cf6bfb79b4661
--------------------------------------------------------------------------------
/project2/flask_session/c2812e98b565014cd16ea68651cba8c3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/c2812e98b565014cd16ea68651cba8c3
--------------------------------------------------------------------------------
/project2/flask_session/de07fbaca02d27362baf6b21f8229296:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/de07fbaca02d27362baf6b21f8229296
--------------------------------------------------------------------------------
/project2/flask_session/ed7fed788b661e92b67c97a5d6978070:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/ed7fed788b661e92b67c97a5d6978070
--------------------------------------------------------------------------------
/project2/flask_session/f564898882840fceb98756b965d6ce94:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/f564898882840fceb98756b965d6ce94
--------------------------------------------------------------------------------
/project2/flask_session/fbdb6d9a667a7ebaa26f918437f11898:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project2/flask_session/fbdb6d9a667a7ebaa26f918437f11898
--------------------------------------------------------------------------------
/project2/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask
2 | Flask-SocketIO
3 | Flask
4 | Flask-Session
5 | psycopg2
6 | SQLAlchemy
7 | flask_sqlalchemy
8 |
--------------------------------------------------------------------------------
/project2/static/subscribe.js:
--------------------------------------------------------------------------------
1 | document.addEventListener('DOMContentLoaded', () => {
2 |
3 | document.querySelectorAll('button').forEach(button => {
4 | button.onclick = () => {
5 | var channelName = document.querySelector('#channelName').value;
6 | socket.emit('create channel', {'channelName': channelName});
7 | };
8 | });
9 |
10 |
11 | });
12 |
--------------------------------------------------------------------------------
/project2/templates/error.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Error
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Error
9 |
10 |
11 |
{{ message }}
12 |
13 |
14 |
17 | {% endblock %}
--------------------------------------------------------------------------------
/project2/templates/index.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Index
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Index
9 |
10 |
11 |
14 |
15 |
18 |
19 |
22 | {% endblock %}
--------------------------------------------------------------------------------
/project2/templates/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% block title %} {% endblock %}
5 |
6 |
7 | {% block head %} {% endblock %}
8 |
9 |
10 |
11 | {% block body %}
12 | {% endblock %}
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/project2/templates/login.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Login
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Login
9 |
21 |
22 |
25 |
26 | {% endblock %}
--------------------------------------------------------------------------------
/project2/templates/register.html:
--------------------------------------------------------------------------------
1 | {% extends "layout.html" %}
2 |
3 | {% block title %}
4 | Register
5 | {% endblock %}
6 |
7 | {% block body %}
8 | Register
9 |
24 |
25 |
28 | {% endblock %}
--------------------------------------------------------------------------------
/project3/Procfile:
--------------------------------------------------------------------------------
1 | web: gunicorn deployProject.wsgi --log-file -
2 |
--------------------------------------------------------------------------------
/project3/README.md:
--------------------------------------------------------------------------------
1 | # Project 3
2 |
3 | Web Programming with Python and JavaScript
4 |
--------------------------------------------------------------------------------
/project3/db.sqlite3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/db.sqlite3
--------------------------------------------------------------------------------
/project3/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import os
3 | import sys
4 |
5 | if __name__ == "__main__":
6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pizza.settings")
7 | try:
8 | from django.core.management import execute_from_command_line
9 | except ImportError as exc:
10 | raise ImportError(
11 | "Couldn't import Django. Are you sure it's installed and "
12 | "available on your PYTHONPATH environment variable? Did you "
13 | "forget to activate a virtual environment?"
14 | ) from exc
15 | execute_from_command_line(sys.argv)
16 |
--------------------------------------------------------------------------------
/project3/orders/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__init__.py
--------------------------------------------------------------------------------
/project3/orders/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/__pycache__/admin.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/admin.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/__pycache__/apps.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/apps.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/__pycache__/models.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/models.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/__pycache__/views.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/__pycache__/views.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 |
3 | from .models import *
4 |
5 | # Register your models here.
6 | admin.site.register(TypeOfPizza)
7 | admin.site.register(Size)
8 | admin.site.register(SizeOfPizza)
9 | admin.site.register(Pizza)
10 | admin.site.register(PriceOfPizza)
11 | admin.site.register(ItemOrder)
12 | admin.site.register(Order)
13 | admin.site.register(Sub)
14 | admin.site.register(PriceOfSub)
15 | admin.site.register(Dinner)
16 | admin.site.register(PriceOfDinner)
17 | admin.site.register(Topping)
18 | admin.site.register(Pasta)
19 | admin.site.register(Salad)
--------------------------------------------------------------------------------
/project3/orders/apps.py:
--------------------------------------------------------------------------------
1 | from django.apps import AppConfig
2 |
3 |
4 | class OrdersConfig(AppConfig):
5 | name = 'orders'
6 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-17 18:58
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | initial = True
9 |
10 | dependencies = [
11 | ]
12 |
13 | operations = [
14 | migrations.CreateModel(
15 | name='Size',
16 | fields=[
17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18 | ('name', models.CharField(max_length=64)),
19 | ],
20 | ),
21 | migrations.CreateModel(
22 | name='TypeOfPizza',
23 | fields=[
24 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
25 | ('name', models.CharField(max_length=64)),
26 | ],
27 | ),
28 | ]
29 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0003_auto_20181117_2321.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-18 01:21
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0002_auto_20181117_2215'),
10 | ]
11 |
12 | operations = [
13 | migrations.AlterField(
14 | model_name='pizza',
15 | name='numberOfToppings',
16 | field=models.IntegerField(default=0),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0004_auto_20181117_2339.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-18 01:39
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('orders', '0003_auto_20181117_2321'),
11 | ]
12 |
13 | operations = [
14 | migrations.AlterField(
15 | model_name='pizza',
16 | name='typeOfPizza',
17 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pizzas', to='orders.TypeOfPizza'),
18 | ),
19 | migrations.AlterField(
20 | model_name='priceofpizza',
21 | name='pizza',
22 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='prices_of_pizza', to='orders.Pizza'),
23 | ),
24 | ]
25 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0005_auto_20181118_0249.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-18 04:49
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('orders', '0004_auto_20181117_2339'),
11 | ]
12 |
13 | operations = [
14 | migrations.AlterField(
15 | model_name='priceofsub',
16 | name='sub',
17 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='prices_of_sub', to='orders.Sub'),
18 | ),
19 | ]
20 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0007_sizeofpizza_typeofpizza.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-20 17:31
2 |
3 | from django.db import migrations, models
4 | import django.db.models.deletion
5 |
6 |
7 | class Migration(migrations.Migration):
8 |
9 | dependencies = [
10 | ('orders', '0006_auto_20181120_1512'),
11 | ]
12 |
13 | operations = [
14 | migrations.AddField(
15 | model_name='sizeofpizza',
16 | name='typeOfPizza',
17 | field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='orders.TypeOfPizza'),
18 | preserve_default=False,
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0008_remove_pizza_typeofpizza.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-20 17:45
2 |
3 | from django.db import migrations
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0007_sizeofpizza_typeofpizza'),
10 | ]
11 |
12 | operations = [
13 | migrations.RemoveField(
14 | model_name='pizza',
15 | name='typeOfPizza',
16 | ),
17 | ]
18 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0009_pizza_description.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-20 20:21
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0008_remove_pizza_typeofpizza'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='pizza',
15 | name='description',
16 | field=models.CharField(default='', max_length=128),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0010_auto_20181120_1825.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-20 20:25
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0009_pizza_description'),
10 | ]
11 |
12 | operations = [
13 | migrations.AlterField(
14 | model_name='pizza',
15 | name='description',
16 | field=models.TextField(default=''),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0011_auto_20181120_1830.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-11-20 20:30
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0010_auto_20181120_1825'),
10 | ]
11 |
12 | operations = [
13 | migrations.AddField(
14 | model_name='dinner',
15 | name='description',
16 | field=models.TextField(default=''),
17 | ),
18 | migrations.AddField(
19 | model_name='pasta',
20 | name='description',
21 | field=models.TextField(default=''),
22 | ),
23 | migrations.AddField(
24 | model_name='salad',
25 | name='description',
26 | field=models.TextField(default=''),
27 | ),
28 | ]
29 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0013_order_user.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-12-01 00:00
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12 | ('orders', '0012_auto_20181130_1847'),
13 | ]
14 |
15 | operations = [
16 | migrations.AddField(
17 | model_name='order',
18 | name='user',
19 | field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='items', to=settings.AUTH_USER_MODEL),
20 | preserve_default=False,
21 | ),
22 | ]
23 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0014_auto_20181130_2307.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-12-01 01:07
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0013_order_user'),
10 | ]
11 |
12 | operations = [
13 | migrations.AlterField(
14 | model_name='order',
15 | name='date_delivered',
16 | field=models.DateField(null=True),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0015_auto_20181201_0154.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-12-01 03:54
2 |
3 | from django.conf import settings
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 |
7 |
8 | class Migration(migrations.Migration):
9 |
10 | dependencies = [
11 | ('orders', '0014_auto_20181130_2307'),
12 | ]
13 |
14 | operations = [
15 | migrations.AlterField(
16 | model_name='order',
17 | name='user',
18 | field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='orders', to=settings.AUTH_USER_MODEL),
19 | ),
20 | ]
21 |
--------------------------------------------------------------------------------
/project3/orders/migrations/0016_auto_20181201_0204.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 2.0.3 on 2018-12-01 04:04
2 |
3 | from django.db import migrations, models
4 |
5 |
6 | class Migration(migrations.Migration):
7 |
8 | dependencies = [
9 | ('orders', '0015_auto_20181201_0154'),
10 | ]
11 |
12 | operations = [
13 | migrations.AlterField(
14 | model_name='order',
15 | name='date_delivered',
16 | field=models.DateField(blank=True, null=True),
17 | ),
18 | ]
19 |
--------------------------------------------------------------------------------
/project3/orders/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__init__.py
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0001_initial.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0001_initial.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0002_auto_20181117_2215.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0002_auto_20181117_2215.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0003_auto_20181117_2321.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0003_auto_20181117_2321.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0004_auto_20181117_2339.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0004_auto_20181117_2339.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0005_auto_20181118_0249.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0005_auto_20181118_0249.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0006_auto_20181120_1512.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0006_auto_20181120_1512.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0007_sizeofpizza_typeofpizza.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0007_sizeofpizza_typeofpizza.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0008_remove_pizza_typeofpizza.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0008_remove_pizza_typeofpizza.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0009_pizza_description.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0009_pizza_description.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0010_auto_20181120_1825.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0010_auto_20181120_1825.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0011_auto_20181120_1830.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0011_auto_20181120_1830.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0012_auto_20181130_1847.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0012_auto_20181130_1847.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0013_order_user.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0013_order_user.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0014_auto_20181130_2307.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0014_auto_20181130_2307.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0015_auto_20181201_0154.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0015_auto_20181201_0154.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/0016_auto_20181201_0204.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/0016_auto_20181201_0204.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/migrations/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/migrations/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/static/orders/css/fonts/icomoon.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/css/fonts/icomoon.eot
--------------------------------------------------------------------------------
/project3/orders/static/orders/css/fonts/icomoon.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/css/fonts/icomoon.ttf
--------------------------------------------------------------------------------
/project3/orders/static/orders/css/fonts/icomoon.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/css/fonts/icomoon.woff
--------------------------------------------------------------------------------
/project3/orders/static/orders/fonts/icomoon.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/fonts/icomoon.zip
--------------------------------------------------------------------------------
/project3/orders/static/orders/img/rest-bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/img/rest-bg.jpg
--------------------------------------------------------------------------------
/project3/orders/static/orders/img/rest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/static/orders/img/rest.png
--------------------------------------------------------------------------------
/project3/orders/templatetags/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/templatetags/__init__.py
--------------------------------------------------------------------------------
/project3/orders/templatetags/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/templatetags/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/templatetags/__pycache__/helpers.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/orders/templatetags/__pycache__/helpers.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/orders/templatetags/helpers.py:
--------------------------------------------------------------------------------
1 | from django.template import Library
2 |
3 | register = Library()
4 |
5 | @register.filter
6 | def get_range(value):
7 | return range(value)
8 |
9 | @register.filter
10 | def get_add(value, arg):
11 | return value+arg
12 |
13 | @register.filter
14 | def isGreaterThanZero(value):
15 | return value>0
16 |
17 | @register.filter
18 | def get_multiply(value, arg):
19 | return value*arg
20 |
21 | @register.filter
22 | def stringIsEqual(value, arg):
23 | return value==arg
24 |
25 | @register.filter
26 | def stringIsDifferent(value, arg):
27 | return value!=arg
--------------------------------------------------------------------------------
/project3/orders/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/project3/orders/urls.py:
--------------------------------------------------------------------------------
1 | from django.urls import path
2 |
3 | from . import views
4 |
5 | urlpatterns = [
6 | path("", views.index, name="index"),
7 | path("register", views.auth_register, name="register"),
8 | path("logout", views.auth_logout, name="logout"),
9 | path("add_item", views.add_item, name="add_item"),
10 | path("edit_quantity", views.edit_quantity, name="edit_quantity"),
11 | path("remove_item", views.remove_item, name="remove_item"),
12 | path("update_progress", views.update_progress, name="update_progress"),
13 | path("orders", views.orders, name="orders"),
14 | path("submit_order", views.submit_order, name="submit_order"),
15 | path("cart", views.cart, name="cart"),
16 | path("login", views.auth_login, name="login")
17 | ]
18 |
--------------------------------------------------------------------------------
/project3/pizza/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/pizza/__init__.py
--------------------------------------------------------------------------------
/project3/pizza/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/pizza/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/pizza/__pycache__/settings.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/pizza/__pycache__/settings.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/pizza/__pycache__/urls.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/pizza/__pycache__/urls.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/pizza/__pycache__/wsgi.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vdhug/CS50-Web-Programming-with-Python-and-JavaScript/176df85315bbbfb440ec4498e08ea0970420e2b2/project3/pizza/__pycache__/wsgi.cpython-37.pyc
--------------------------------------------------------------------------------
/project3/pizza/urls.py:
--------------------------------------------------------------------------------
1 | """pizza URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/2.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import include, path
18 |
19 | urlpatterns = [
20 | path("", include("orders.urls")),
21 | path("admin/", admin.site.urls),
22 | ]
23 |
--------------------------------------------------------------------------------
/project3/pizza/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for pizza project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pizza.settings")
15 |
16 | application = get_wsgi_application()
17 |
18 | # Use whitenoise package to serve static files on Heroku
19 | from whitenoise.django import DjangoWhiteNoise
20 | application = DjangoWhiteNoise(application)
21 |
--------------------------------------------------------------------------------
/project3/requirements.txt:
--------------------------------------------------------------------------------
1 | Django==2.0.3
2 | python-3.7.0
3 | whitenoise==3.2.1
4 | gunicorn==19.6.0
5 | dj-database-url==0.5.0
6 | psycopg2==2.7.1
7 |
--------------------------------------------------------------------------------
/project3/runtime.txt:
--------------------------------------------------------------------------------
1 | python-3.7.0
2 |
--------------------------------------------------------------------------------