Web Development with Python Tutorial - Flask & Dynamic Database-Driven Web Apps
HTML-код
- Опубликовано: 23 июл 2024
- Learn how to develop Dynamic Database-Driven Web Apps with Python, Flask, and MySQL. This course is broken up into two parts. In part one, you will learn how to build and deploy a site using the Flask Python web framework. In part two, you will connect the Flask application from the first part to a cloud MySQL database and learn how to deploy a production-ready database-driven web application.
✏️ Aakash N S created this course.
🔗 Submit your project & earn a certificate: jovian.com/learn/web-developm...
🔗 Check out Jovian’s RUclips channel: / @jovianhq
Notes & references links:
🔗 Part 1: jovian.com/aakashns/web-devel...
🔗 Part 2: jovian.com/aakashns/database-...
⭐️ Contents ⭐️
Part 1
⌨️ (0:00:00) Introduction
⌨️ (0:02:07) 1.1 Project Setup & Flask Basics
⌨️ (0:22:25) 1.2 Building Web Pages using HTML
⌨️ (0:40:57) 1.3 Styling with CSS & Bootstrap
⌨️ (1:08:25) 1.4 Dynamic Data using Templates
⌨️ (1:27:22) 1.5 Deploying to the Cloud with Render
⌨️ (1:42:39) 1.6 Functional and Aesthetic Improvements
⌨️ (1:58:44) 1.7 Summary & Future Work
Part 2
⌨️ (2:04:19) Database-Driven Web Applications
⌨️ (2:07:24) 2.1 Project Setup & Deployment
⌨️ (2:21:44) 2.2 Cloud MySQL Database Setup
⌨️ (2:36:20) 2.3 DB Connection with SQLAlchemy
⌨️ (2:56:22) 2.4 Display DB Data on Web Page
⌨️ (3:20:04) 2.5 Dynamic Database-Driven Pages
⌨️ (3:49:23) 2.6 HTML Form for Applications
⌨️ (4:15:37) 2.7 Saving Applications to DB
⌨️ (4:26:23) 2.8 Summary & Future Work
⌨️ (4:37:50) Conclusion
🎉 Thanks to our Champion and Sponsor supporters:
👾 Nattira Maneerat
👾 Heather Wcislo
👾 Serhiy Kalinets
👾 Erdeniz Unvan
👾 Justin Hual
👾 Agustín Kussrow
👾 Otis Morgan
--
Learn to code for free and get a developer job: www.freecodecamp.org
Read hundreds of articles on programming: freecodecamp.org/news
We hope you enjoy this tutorial, and we look forward to seeing what you'll build! If you'd like to get your project reviewed by our team & earn a certificate, register here for free: jovian.com/learn/web-development-with-python-and-flask
If you have any questions or face issues, please post them in the comments and we'll help you out. Do check out our RUclips channel as well, where we're posting new tutorials every week.
Thanks @freecodecamp and Beau for hosting us! 🙏🏼
Thanks!
I am stuck at the function "def load_jobs_from_db()". I keep getting "TypeError: cannot convert dictionary update sequence element #0 to a sequence"... Little help here please...
@@bosserichie5578
Good day everyone.
I want to express my deep gratitude to the author of the course for the work done. Thank you, your course is very informative.
I'm having some problems in the code at 4:20.
I understand that this is due to the fact that the version of the SQLAlchemy is 2.0.4.
Solved it like this:
def add_application_to_db(job_id, data):
a=data["full_name"][0]
b=data['email'][0]
c=data["linkedin_url"][0]
d=data['education'][0]
e=data['work_experience'][0]
f=data['resume_url'][0]
with engine.connect() as conn:
conn.execute(text(f"INSERT INTO applications (job_id, full_name, email, linkedin_url, education, work_experience, resume_url) VALUES ({job_id}, '{a}','{b}','{c}', '{d}', '{e}', '{f}')"))
At the same time, in the "app.py" file, you need to change the dictionary to: "data = request.form.to_dict (flat = False)" because Flask returns a dictionary of the "ImmutableMultiDict" type, and we need a simple dictionary()
All success in your studies!
@@bosserichie5578 Try asking this question on the course discussions page, our team will reply: jovian.com/learn/web-development-with-python-and-flask/discussions
@@jovianhq Hi, I am new to using replit. I followed exactly what you did but am getting this error:
"sh: line 1: python: command not found exit status 127"
Any idea how to fix this?
what a tutorial, started from zero, by the end got almost everything, on my way of building personal projects with obtained skills and knowledge!!
You are a super teacher. I wish we could teach students in the University in such granularity and functionality. There is no point dumping boring theories onto students' brain about www, HTTP, etc. Tutorials like this puts everything into context. Well done and thank you so much for making and sharing these contents.
Aakash has been a very big blessing to my career. I had an interview and somehow passing Algorithms through code challenges was difficult. But the moment i lay hold of Aakash tutorial on Data structures and algorithms. After going through the course this time i went into the test and came out successful. Thank you Co-founder of Jovian Aakash
This is gold! The flow was absolutely flawless and understood without having to rewind and watch. Great stuff! 👌
Thanks, we're glad you liked it!
Thank you Aakash and freeCodeCamp for taking the time to create and share this video it was a great walk through for flask and mysql in the cloud!!
The fact that this is available is fantastic!
This is Awesome. Please continue with the next steps!! This Content is GOLD!!
I usually don't comment on videos but this one is super helpful. cheers to you man , This was flawless
First, I'd like to say this is one of the most fluid and well explained coruses i've ever taken
Thanks, we're glad you enjoyed the course!
This was absolutely amazing, built a fully packaged website with dynamic data and email linked, basically everything
Thanks! There's definitely a lot more to web development that we haven't covered here, but we wanted to demonstrate that the end-to-end process of a fully functional website isn't as long or hard as it seems. 🙂
@Jovian Absolutely, but for a starter guide this covered tons of features. I was able to build a well packaged web just by following your tutorial. Thanks again and keep up the great work 👍
@@jovianhq law, cantonment, religious theology, business naming, economy, history, literature, surrounding flora and fauna is related to all Jews mastermind game, why we need to disguise or mockery that we are different. the thing is everyone is on the same page
can you please provide the correct and complete link of jovian image
sir, you are the best. Just started with web development and i literally understood everything without any problem. thank you very much
can you please provide the correct and complete link of jovian image link
Absolutely love this course.. Thank you 🙂
Thanks, we're glad you found it useful!
Wow ! Wow ! Wow ! Wow !!! This is just absolutely fantastic. This is a whole career
If you had trouble converting to dict at around 2h:54m, apparently Legacy.Row is out of date. This worked for me:
with engine.connect() as conn:
result = conn.execute(text("select * from jobs"))
result_all = result.all()
first_result = result_all[0]
column_names = result.keys()
first_result_dict = dict(zip(column_names, first_result))
print(first_result_dict)
with engine.connect() as conn:
result = conn.execute(text("select * from jobs"))
column_names = result.keys()
result_dicts = []
for row in result.all():
result_dicts.append(dict(zip(column_names, row)))
print(result_dicts)
@@caiozendron5024 thanks thats great, how did you work this out?
@@caiozendron5024 Thank you very much 🙌, I was really stuck at this point.
@@caiozendron5024 thanks it was useful
for anyone who is stuck with other func.
for 'load_job_from_db()' function it should work like this:
def load_job_from_db(id):
# CREATE "LIST" OF row with id
with engine.connect() as conn:
query = "SELECT * FROM jobs WHERE ID={}".format(id)
result = conn.execute(text(query))
column_names = result.keys()
result_dicts = []
rows = result.all()
if len(rows) == 0:
return None
for row in rows:
result_dicts.append(dict(zip(column_names, row)))
return (result_dicts)
Cool bro! Thanks a lot.
For those experiencing some issues around 3:29, this worked for me
def load_job_from_db(id):
with engine.connect() as conn:
result = conn.execute(
text(f"SELECT * FROM jobs WHERE id={id}")
)
rows = []
for row in result.all():
rows.append(row._mapping)
if len(rows) == 0:
return None
else:
return row
Thanks for the code! For my case, I had to modify the last part. You saved the day. Cheers!
rows = result.all()
if len(rows) == 0:
return None
else:
return dict(rows[0]._asdict())
can you please provide the correct and complete link of jovian image
For those facing issue related to the TypeError while appending the row in the result_dict at 2:56:00 can use result_dicts.append(row._mapping), i was also facing this issue wasted around 2 Hrs to figure it out!
You made my day! I was looking to why I was having this error and I looked online but I could not get around it. Thanks a bunch!
wow thank you so much!!!! You help me a lot ;)
👍👍👍
bhai bhai bhai!!!! :)
Thank You!!
thanks a lot man that really helped
Thank you for this, so well-explained and comprehensive!
You're welcome! 🙂
This is a very good tutorial. You will learn flask, how to deploy on render and hosting.
Always keep it up! You're doing great! 👍👍👍👍👍
Thanks, we're glad you enjoyed the tutorial!
By far the best tutorial I have seen, explaining the end to end workflow and resolving errors on the go.
Thank you so much FreeCodeCamp and Aakash!!
were you able to create a free database using Planet scale?
Very good tutorial and should help many developers to build on similar lines. Great job 👍
I gained more knowledge from you than I did from my entire college web development course. Thank you, sir.
by far the most easy to understand tutorial I've come across
After many hours i finally finish this course! REally nice to get some practice. Thanks!!! a lot.
can you please provide the correct and complete link of jovian image link
This is actually so helpful, Thank you so much!
The best web development tutorial so far!
easy to Follow and understand.
The course is really cool. the best tutorial for flask for beginners
Thank you bro! It's so cool course for Flask beginner.
Very useful tutorial, thanks a lot, Jovian and Freecodecamp!
RReally thank you it has been a great help. I was trying to learn flask form other sources but this was the most helpful 4.5 hr video.
If you don't get proper dictionary @3:26:50 here is the function that worked for me:
def load_job_from_db(id):
with engine.connect() as conn:
result = conn.execute(text("SELECT * FROM jobs WHERE id = :val"),{'val': id})
row = result.fetchone()
return row._asdict()
Thanks :)
Hey thanks for the solution however, a small edit to your snippet did the magic for me:
def load_work_from_db(id):
with engine.connect() as conn:
result = conn.execute(text("SELECT * FROM work WHERE id = :val"),{'val': id})
row = result.fetchone()
if row:
return row._asdict()
else:
return None
Thing that is a bit confusing to me is why on earth the original code doesn't work. I mean it seems to be working when the Prof is writing it but when I followed his methods it won't work for me.
Anyhow Thanks for sharing your solution!
@@minhajmasood5706 thanks for the fix . i was struggling so bad because of this
Simply great! Thank you for this great step by step project. I can see my project built up by only watching your video. Many many thanks.
can you please provide the correct and complete link of jovian image link
Thank you very much for this tutorial, it helps me a lot to understand how web dev works and to build a good mindset about internet and web dev. thank you very much
In case you are having a problem with the images not being displayed in the /job/id after including the banner.html and nav.html into your jobpage.html around 3:36:33, you will need to go into the banner.html file, in the add ../ to your image source path so it will be like this src="../static/hero.jpeg" and remember to apply the same to nav.html file too. That should fix it. Good luck!
One of the best tutorial I've ever seen about Flask.
can you please provide the correct and complete link of jovian image link
This tutorial is just awesome!! Bro please make one similar video which will include HTML,CSS, Java Script, Angular & Database in that. Mainly I would like to understand how javascript Anular and DB work together.
can you please provide the correct and complete link of jovian image
Web Development with Python Tutorial very helpful video, i learned a lot from here. Looking forward to the next videos
Glad you liked it!
finnaly finish it thank you so much
Muchas gracias fue divertido. Algunas cosas han cambiado pero se pueden realizar.
If you're stuck at 2:56:09 this worked fine for me:
with engine.connect() as conn:
result = conn.execute(text("select * from jobs"))
result_dicts = []
for row in result.all():
result_dicts.append(dict(row._mapping))
print(result_dicts)
Dhanyawad Mitra!
👍👍
You're my hero! Let's just say I should have checked the comments 2 hours ago
Thank you bro
Excellent tutorial. Nothing irrelevant. To the point👌
Great job ! Thank you for this tutorial
wow am grateful for the great work done here💖😄
The tutorial was very impactful. Thank you for putting this togetter
I am grateful to see a tutorial that is not using SQLIte. Looking forward to this. Thank you.
Yeah, we're using PlanetScale to set up a free MySQL database here. You can also use Supabase or Neon if you'd like to use Postgres.
@@jovianhq Gonna finally try neon. Lets see
@@jovianhq Is there another way except giving PlanetScale credit card information?
can you please provide the correct and complete link of jovian image
This was like super useful ! Thank you a lot Sir , I appreciate your work
You're welcome Sebastian! We hope you were able to follow along and deploy your own website.
Thank you for this tutorial. This is a gem.
Just what i needed
Very helpful. Thanks for sharing 👍
Glad you found it helpful!
1:18:42 When I do this, there is no output, because the variable 'job' is not accessed by jobitem.html.
at 2:55:20 if you are stuck with dict( ) conversion, try using ._asdict() method
Apparently it will be like
first_result_dict = result_all[0]._asdict()
thanks DeeJay
Thanks man
How did you manage to push your work to GitHub?
Thank you!
this really works
people can use this as alternate
i am working as a python backend developer this video lot a help me thank you so mush for nice video..
How would you check for the validation of the input data in the forms?
Thank you very much for this course!
You're welcome!
why waste time understanding replit, when you can do it in vscode anyway
issue around 2:47? instead of:
"ca": "/etc/ssl/cert.pem"
use:
"ssl_cert": "/etc/ssl/cert.pem"
Thank you, I was stuck in that part. But I need to know why ? ¿ What is the difference ?
@@kevinleonumana98 "For convenience, the following keys may also be specified inline within the URL where they will be interpreted into the “ssl” dictionary automatically: “ssl_ca”, “ssl_cert”, “ssl_key”, “ssl_capath”, “ssl_cipher”, “ssl_check_hostname”." - it's from the docs.
thanks!
This was great!!
WOW 😃❤
absolutely great tutorial!!!!!
Amazing
best tutorial ever👍👍👍
Hello community! I stucked around 3:18. Does anyone know why after deploying to Render, and building whole app correctly I got error: access denied for user : ..userHameHere... and right after that notification on email from planet scale that 'leaked secret has been revoked' ... database password has been detected in public repository onGH. Any connections using this password will be disconnected. Any ideas how to fix it?
This video is helpful 👍
Hi Akash. Thank you for the detailed tutorial on Python web development. Specially delving into the very basics like HTML and CSS. It is a good refresher as well helped in learning Python web development as a whole.
i am gonna watch it i find it intresting as teaching is good
sos dera friends i received build failed bash pip command not found what should i do?
Amazing lecture!!!
Thanks!
Thank you for this😊
You're welcome, looking forward to seeing what you'll build!
keep posting python courses i love it
Any topics you'd like to learn in particular?
@@jovianhq Django Advanced Topics
@@jovianhq yes i just learned about the basics of python so any advance topic will do
This is Gold bro 👌
Thank you so much Sir
thank you so much your video
when 3rd part of this video is coming? Great work man👍👍
Great Tutorial
Awesome lecture!
Glad you enjoyed it!
i wanted to share the web site i developed using this video cos its my frst time web though i used pycharm cos my code on replit was like #python not found so i knew there aint way after trying many time,i watched this video for two weeks while building my own and learnt everything, aakash is my teacher for life
planetscale have no free plan now....how you access this for free?
@@PodShorts1512 I just checked PlanetScale, it still offer free plan as Hobby.
When creating a New Web Service on render, render ask to enter a payment method as they require payment to proceed further. Can anyone confirm how to go from this step?
Hey if it is possible we look for a tutorial of iot with packet tracer this field is amazing
Thank you very much for this tutorial, i could understand entire tutorial, and make it work on my laptop, render and planetscale, I used PyCharm on my laptop instead of replit, and the insert functionality I had to make some changes to make it work - had to use key value pair : values={'job_id': job_id,
'full_name':data['full_name'],
'email':data['email'],
'linked_url':data['linkedin_url'],
'education':data['education'],
'work_experience':data['work_experience'],
'resume_url':data['resume_url']
} and then add this 'values' to the conn.execute (query, values)
can you please provide the correct and complete link of jovian image
@@ananyachauhan775 You can go to the description and you will get that.
Great Video
Good job! 🤛🏻
Gratitude 🙏👍
Thank you for helping us Africans
😂😂😂
You guy's have electricity??😮
😂😂😂😂
Is not he look like indian..haha😅
@@IamTanmoy28No, we wait for thunderstorms and use the lightning flash to do our school assignments and other things 😢.Sometimes we also read using our father’s cigarette light
Best!
this guy is a god level teacher
Let’s try it
2:22:49 any alternative to Planet Scale because it is asking card details even for the free plan
Brother did you find any?
Is it secure way of accessing database like ORM of sqlalchemy?
one of the best lectures.Akash can you just help me how I can learn/master jinja template
2:36:29 I'm facing error from this sql alchemy after installing sql alchemy the website is not loading
Hi Jovian: I am new in Replit, HTML, Jscript etc. Font Roboto is not making impact while I am using it in CSS. why ? Is there any other config or import of font required ?
It might be because you're not using the Chrome browser. You might need to manually include the font in your CSS file. Follow this guide: stackoverflow.com/a/24274373
For the mySQL database using Planet scale, they do not have a free plan anymore. What's the best alternative?
same concern
How to resolve ModuleNotFoundError: No module named 'flask' error? Please help
I had to install python package at Replit for it to work. Otherwise I get a not found error. Took me an hour to figure it out but it's working now.
hi all,
Facing issueat 3:30:04,during template rendering the title is not dynamically passed in to my html
kidnly provide any work around if anybody faced issue here
thankyou
i can't see the html files in bootstrap examples, i can only see css files. i tried some steps to troubleshoot and figure out the issue but non worked for me. Any further troubleshooting i will appreciate.
Hi am grateful for you video. It's very education. Please i find it difficult to install sqlalchemy on replit (window) while following the video. I need help
I am encountering this error and I am not able to find a solution:
result_dicts.append(dict(row))
TypeError: cannot convert dictionary update sequence element #0 to a sequence
cool video)