CS50x 2024 - Lecture 9 - Flask
Вставка
- Опубліковано 1 чер 2024
- ***
This is CS50, Harvard University's introduction to the intellectual enterprises of computer science and the art of programming.
***
TABLE OF CONTENTS
00:00:00 - Introduction
00:01:01 - Flask
00:27:53 - Forms
00:33:10 - Templates
00:40:36 - Request Methods
00:54:00 - Frosh IMs
01:31:37 - SQLite and Python
01:40:07 - Cookies and Sessions
01:58:33 - Shopping Cart
02:08:30 - Shows
02:18:54 - APIs
***
HOW TO SUBSCRIBE
ua-cam.com/users/subscription_c...
HOW TO TAKE CS50
edX: cs50.edx.org/
Harvard Extension School: cs50.harvard.edu/extension
Harvard Summer School: cs50.harvard.edu/summer
OpenCourseWare: cs50.harvard.edu/x
HOW TO JOIN CS50 COMMUNITIES
Discord: / discord
Ed: cs50.harvard.edu/x/ed
Facebook Group: / cs50
Faceboook Page: / cs50
GitHub: github.com/cs50
Gitter: gitter.im/cs50/x
Instagram: / cs50
LinkedIn Group: / 7437240
LinkedIn Page: / cs50
Medium: / cs50
Quora: www.quora.com/topic/CS50
Reddit: / cs50
Slack: cs50.edx.org/slack
Snapchat: / cs50
SoundCloud: / cs50
Stack Exchange: cs50.stackexchange.com/
TikTok: / cs50
Twitter: / cs50
UA-cam: / cs50
HOW TO FOLLOW DAVID J. MALAN
Facebook: / dmalan
GitHub: github.com/dmalan
Instagram: / davidjmalan
LinkedIn: / malan
Quora: www.quora.com/profile/David-J...
TikTok: / davidjmalan
Twitter: / davidjmalan
***
CS50 SHOP
cs50.harvardshop.com/
***
LICENSE
CC BY-NC-SA 4.0
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
creativecommons.org/licenses/...
David J. Malan
cs.harvard.edu/malan
malan@harvard.edu
Seeing David use the duck made me realize I’m not alone. Such a real moment Love this course so much.
This is the big reckoning, so much is connecting together. My head hurts but I am not giving up this far.
This is the way.
I just looked at Problem Set 9 Finance and it truly does all come together. Quite overwhelming
Keep it up and enjoy every minute of it...❤
"Let me go ahead and PROPOSE that...." Bingo! Classic David. I wish we had Profs like DM when I was at school.
The moment with the DDB was hands down my favorite moment so far in these lectures. So relatable and David’s reaction was honestly adorable 😅 so he is human too…
ok this really fried my brain. Thank you for the efforts, will need to let that sink in.
Thank you team @CS50
I’m really thankful for this class. It really feels like I am part of the class and that duck debugger moment get so relatable
This man is a legend and the best teacher that I found till now...
Lots of love and respect to prof. David J. Malan and the entire team of CS50
Thanks once again for an amazing and helpful content. Cheers to 2024 🎉
after every lecture i watch, i tend to think to myself how i would've coped if i was a complete beginner. even with a year of coding, this course is hard
this course is really easy
just no@@prcvl
I was a complete beginner when I took this course 2 years ago. I don't think it's that hard. In fact because of it, I fell in love with Computer science and now I'm half way through my degree.😊
@@prcvlthis was a productive and positive comment. this is the kind of comment that makes people value your input and become your friend.
i came from the odin project - the insight this course provides is the difference between blind flailing and planned execution
Awesone Video . Simultaneously coding helps to understand the concept
Do you use fuel monitor.
If you are following this at home your won't have access to the same environment as David. Advisable to create virtual environment in 'hello' and run flask that way. Django would have been nice but DM's teaching is world class.
6:36 This is actually a very good definition for a so-called "framework" that I never really thought about before. It's not just third-party code. But it's third-party conventions as well.
Which means you may have to learn a whole new syntax, etc.
Every lesson fulfills my brain with so much information and this is no exception.
great class... definitely not for beginning beginners but more for advanced beginners
Почему так много людей пишет, что курс сложный?!) Я программирую пару месяцев и этот курс выглядит максимально понятным и доступным для всех!
Using the CS50 duck was nice...
But I'm surprised I haven't seen more use of the built-in help function? I don't think it's even been mentioned once? Could be wrong though.
Very easy to use, for example, in the terminal just use >>> help(print) at the prompt. Will tell you everything you need to know about the print function and all its parameters. Same thing for any other object such as a class, function/method, module, list, dict, str, int, etc.
Plus, there's code completion in VS Code or simple dot notation with documentation pop-ups. Has all of that been disabled?
Knowing how to access and read documentation is a skill every developer or programmer needs to know.
That’s the lecture here. A lot but interesting ❤
Coming here to prep for my interview next week for django web dev. I know im gonna learn alot and be entertained.
If something like "this is a lot to process" hits you after watching the lecture, I can say, assertively, you are not alone.
It was nice to see the maestro get flustered but gracefully demo his googling / prompting. That hunch and deep breath was not giving staged 😂
Finally got here, thanks god!
love cs50 flask
Something weird happens at 50:27
AI generated David!🤣
very great
Excellent course quality aside. Is anyone else obsessed with the soundtrack (intro)?
Profesor is hilarious 😂
Thank you.
hardest part of the all lecture imo
I have a question about the last bit of this lecture.
Since he got rid of the template search.html and just returned the jsonified list of shows, at what point does the json file get iterated over and converted into a list with the titles of the movies? I'm assuming version 3 of shows has an extra piece of code at index.html that does that, right?
This is helpful ❤
i faced some trouble with the cart app, the session["cart"] is that holds the list containing the id's of books added to the cart isn't working, after debugging and printing the values i always find myself passing an empty list to the cart.html, i tried to figure what's going on and found out that the Sqlite command to books = db.execute("SELECT * FROM books WHERE id IN (?)", session["cart"]) didn't want to work, it seems that the syntax somehow wrong and even chatgpt told me that maybe sqlite is expecting multiple "?" to process the list and not only one "?" to use the list, but for professor David it's working fine, note: i didn't implement the logic manually i literally downloaded the file src9, any idea guys ?
i found the solution, i will post it here if someone got stuck with this problem, after debugging and adding another list of my own, like this : if book_id:
session["cart"].append(book_id)
list_test.append(book_id) , i noticed that session["cart"] didn't add all the id's appended to it but list_test had all the values in it, so it was a problem of consistency from session["cart"], the solution after explaining the issue to duck debugger was to add this line : session.modified = True | after appending to the session["cart"] , it seems that this line just tells flask that the session got some new changes. i'm using flask on my local machine and running the server on my windows not codespace so probably that's the issue.
I faced the same problem. Another way to solve it is to change this line of code from:
session["cart"].append(book_id)
to:
cart = session["cart"]
cart.append(book_id)
session["cart"] = cart
It's not the best solution, but it works
I got a little lost in this episode, I think it was the Jinja stuff. The duck saving the day was amazing.
Really wish you would've introduced the label tag, instead of using the placeholder-attribute, which is kind of terrible for multiple UX and accessibility reasons 😟
in my virtual workplace " flask run" give me an error in a web page 🙄
Yup me too
I'm going to make it 🔥🔥🔥🔥🔥
This was the last one? great content, btw
4th comment? also thanks cs50, amazing course from which I have learned a lot
Understood++
My last week 🎉🎉🎉🎉😂
I love the moment of David with DDB 😂 He was honest and adorable and It's what all devs do when they get stuck 😂
How come in the shows part, the html placeholder is {{show}} while in the app.py file the variable is show(singular) and it still works?
Unless I'm mistaken, it's because Flask uses Jinja as a template engine. Jinjas syntax uses double brackets while python only singular. But double check the jinja documentation so im not lying to you lol
Anyone know how to open a terminal after I accidentally close all the terminal?
Привет из Ленинградского государственного университета 🤙
2:05:35 not working for me. Any solution!
这个教程真的很牛逼
❤❤
app = Flask(__name__) Is this calling a function or creating an object from the class Flask? Can someone explain this, please? (on minute 12:22 more or less)
Ok I found this so now I understand that better:
In Python, classes can be callable, which means they can behave like functions when called. When you use Flask() in Flask, you're actually calling the Flask class, which acts as a constructor function to create a new instance of the Flask application. So, to clarify, Flask() is both a class and a function. It's a class because it defines the blueprint for Flask applications, and it's a function because you use it to instantiate objects of that class.
had to watch this at 0.9 speed LOL 😅
01:22:00 wow. I can estimate the amount of sweat drip down his back while his code is not working in front of hundred of students.😅
Why they using flask ? Why not FastApi
Flask is better
Flask is simpler for students to understand as many of us are beginners who are taking CS50 as their first course.
It's always strange when people act like they know more then the teacher. The entire course curated the way it is for a reason.
2nd comment?
What a good duck. 😄
But... CS50's staff is smarter than this. I'm sure it was all made up just to show the AI off. 😂