Тёмный

Creating a Weather App in Flask Using Python Requests [Part 1] 

Pretty Printed
Подписаться 96 тыс.
Просмотров 81 тыс.
50% 1

This video demonstrates how to create a weather app in Flask using the Open Weather App API with Python requests.
WORK WITH ME👇🏼
✅ Implement features and fix bugs in your app: Live, one-on-one screenshare
prettyprinted....
💻 Code written in video
prettyprinted....
Join my free course on the basics of Flask-SQLAlchemy: prettyprinted....

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 94   
@prettyprinted
@prettyprinted 4 года назад
Join my free course on the basics of Flask-SQLAlchemy: prettyprinted.com/flasksql
@lukkash
@lukkash 4 года назад
At last some GOOD, meaningful and truly helpful video tutorial on Flask. Thanks a lot!
@imbayi
@imbayi 6 лет назад
Awesome! I followed the example with Django and now we have the same in Flask. Simply amazing.
@prettyprinted
@prettyprinted 6 лет назад
Glad you like the video.
@tx6723
@tx6723 6 лет назад
flask > django(for beginners/small projects/testing stuff/otherstuff)
@TorIvanBoine
@TorIvanBoine 5 лет назад
Nice video. Like that you "included" some errors and debugging :)
@prettyprinted
@prettyprinted 5 лет назад
haha it's more educational and it saves time on editing.
@tusharverma2212
@tusharverma2212 6 лет назад
for better understanding of json objects and array you can use the json viewer extension
@prettyprinted
@prettyprinted 6 лет назад
I'll check it out, thanks.
@woltron4o
@woltron4o 4 года назад
Thanks nice video. This is my first flask tutorial from your videos that I made. it's nice. :)
@mukammedalimbet2351
@mukammedalimbet2351 4 года назад
Thanks for making such an amazing tutorial, however I have a question, When database get created, why tables were created for name exactly 'city'?, did you define it somehow? because as I understand the model was for City with capital C but not city
@puurusottamsaha8971
@puurusottamsaha8971 4 года назад
really nice explanation ..Thanks a lot
@VinayKumar-dc5qg
@VinayKumar-dc5qg 4 года назад
Excellent tutorial
@사공용협
@사공용협 4 года назад
Thanks for your tutorial! I have some question about requests.get() function. When I use >>>flask.request.form.get(url.format(city)), it's not working.(it comes 'None' data) What is the problem?
@townheadbluesboy
@townheadbluesboy 6 лет назад
Very clear and helpful - thanks
@prettyprinted
@prettyprinted 6 лет назад
Thanks for watching!
@zsoltszakal6893
@zsoltszakal6893 3 года назад
It would have been nice to include the starter weather.html....
@ericsclafani9425
@ericsclafani9425 Год назад
Exactly what I was thinking
@kelvinanku-etu2839
@kelvinanku-etu2839 6 лет назад
Love your tutorials. Anything for us kivy??
@leustad
@leustad 6 лет назад
Keep them coming. Very good !! I know you are following what you did with Django but maybe you might wanna mention about using cookies for cities rather than using a DB for this simple project. Just a though.
@prettyprinted
@prettyprinted 6 лет назад
That's a good idea. I'll consider it for a video.
@leustad
@leustad 6 лет назад
I'm not trying to backseat drive your videos, hope you are not taking this in that way. I like your videos, I was simply trying to say what I would do. BTW, we want more of these videos :)
@richarddankwah3088
@richarddankwah3088 2 года назад
Everything in the Vedio is perfect, But we need an update where the App can automatically Record the DATE, TIME, DAY, WIND, HUMIDITY, VISIBILITY, PRESSURE, TEMPERATURE, LONGITUDE AND LATITUDE CORDINATE OF THE CITY into a DataBase for about a Year records when you can retrieve as CSV or Json file by clicking a button and use for your Personal Project on weather data. Thank you.
@everythinginpython3327
@everythinginpython3327 5 лет назад
The weather widget part is not showing up. Neither on chrome nor on firefox
@prettyprinted
@prettyprinted 5 лет назад
I'll have to look into to see if anything has changed. Thanks for letting me know.
@sahanabpradhyumna
@sahanabpradhyumna 5 лет назад
@@prettyprinted Yes, even I m facing the same. The JSON data is displaying in the console but it is not showing in the browser. Whereas when I give the data as static data also, it is not coming but when I load the HTML page as a file path that time is showing. Please update. Flask version I m using is 1.0.2.
@oyajitricker
@oyajitricker 4 года назад
Fantastic Video, I am learning alot! So I did some debugging and the jinja syntax must have changed. I deleted all the jinja references, removed the dict from app.py and ran it. the widget popped right up. Also I updated bulma.css to the latest version. Hope this helps!
@fruitfcker5351
@fruitfcker5351 6 лет назад
Hey man, love your Python Bottle videos. Any chance you'll do Falcon as well? Just subscribed.
@prettyprinted
@prettyprinted 6 лет назад
I'll consider Falcon. Thanks for watching!
@NIKHITAGARGBCE
@NIKHITAGARGBCE 2 года назад
'sqlite3' is not recognized as an internal or external command, operable program or batch file.
@dmc549
@dmc549 5 лет назад
Great tutorial. Subscribed.
@prettyprinted
@prettyprinted 5 лет назад
Thanks for watching and for subscribing!
@SunriseBusinessClub
@SunriseBusinessClub 4 года назад
Why you write the code like this? 'temperature': r['main']['temp'], 'description': r['weather'][0]['description'], Where u get it from, I don't understand
@AbhishekKumar-mq1tt
@AbhishekKumar-mq1tt 6 лет назад
Thank u for this awesome video
@prettyprinted
@prettyprinted 6 лет назад
Thank you for watching.
@prodsefv
@prodsefv 4 года назад
nice video
@vaishnavibhosale2272
@vaishnavibhosale2272 Год назад
do you have a weather forecast project report
@nikhileswar915
@nikhileswar915 3 года назад
url for open weather app api is not same as in video and description, please help me out
@riskcatriax
@riskcatriax 3 года назад
when i try to import db from app.. No module named 'app' shows up what to do?
@rakeshreddy1365
@rakeshreddy1365 3 года назад
>>> from app import db Traceback (most recent call last): File "", line 1, in ImportError: cannot import name 'db' from 'app' (C:\Users\HP\Desktop\WEATHER_APP\app.py)
@VishalKumar-gf8fr
@VishalKumar-gf8fr 6 лет назад
sir temperature is not accurate...can you please check this....
@YASHDEWANGAN
@YASHDEWANGAN 4 года назад
hey , sqlite3 .db is not working on VS code plz. help me
@jimchrist-x
@jimchrist-x 4 года назад
what's the output?
@shivamkapoor1827
@shivamkapoor1827 5 лет назад
22:04 What is the working of request.form.get ('city')
@rohan1765
@rohan1765 4 года назад
To get the value from the input we are having in the browser ( the city name ) and getting it here in flask's main.py.
@uditmittal67
@uditmittal67 6 лет назад
Ironic how you didn't use pprint module for viewing JSON results xD
@prettyprinted
@prettyprinted 6 лет назад
I always forget that it exists. And I'm the last person who should forget about it.
@ahmeddanial1342
@ahmeddanial1342 2 года назад
How do we hide an api key?
@kritikaberry5056
@kritikaberry5056 4 года назад
Hey, why do we use units=imperial in the url, while in api documentation , it has not been mentioned
@satvikgs5855
@satvikgs5855 3 года назад
i jus looked it in their documentation its optional tho..if you dont use you would get it in celsius.
@nits_koh
@nits_koh 4 года назад
Can I run flask on github pages?
@ajaykushwaha6137
@ajaykushwaha6137 5 лет назад
Hey, Thanks for posting such detailed and meaningful videos. I really appreciate this effort and service of yours. I went through the tutorial it worked fine for a while, but later it started giving me an internal server error with a message in the Browser: Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. Also there in the console screen it displays : ERROR in app: Exception on / [GET] Really tried debugging this error, didn't get any luck........can Help?
@prettyprinted
@prettyprinted 5 лет назад
That's not enough information. It could be anything. Try putting your app into debug mode.
@chinmayeehota216
@chinmayeehota216 5 лет назад
How would it update the weather, even when you are not refreshing the page manually, like by constantly polling data from API?
@prettyprinted
@prettyprinted 5 лет назад
You'd have to use some JavaScript for that. It's pretty easy to do if you have experience with JavaScript, but it's hard to explain here.
@jimchrist-x
@jimchrist-x 4 года назад
@@prettyprinted I believe you can also use a meta tag that refreshes the webpage
@SunriseBusinessClub
@SunriseBusinessClub 4 года назад
What is r['main'] what r means? Where u took it from?
@jimchrist-x
@jimchrist-x 4 года назад
r is the connection he makes to the weathermap api. Now if you have some knowledge of lists, json files you can get the specific data that you may want. What he does is r returns huge list ['main'] data for weather he wants to take. This comment is 3 months old so you might already know :)
@akramelomrani8728
@akramelomrani8728 4 года назад
Help please the image do not want to display
@Feng-fw2qy
@Feng-fw2qy 6 месяцев назад
Me too. Any way to solve?
@mxd8
@mxd8 5 лет назад
I get a weird error at 13 min mark when trying to {% include 'weather.html' %} in my index file, [separate routes, my weather route is not the same as the index route] -> jinja2.exceptions.UndefinedError: 'weather' is undefined, can't seem to solve issue, any ideas? thanks!
@prettyprinted
@prettyprinted 5 лет назад
make sure the weather variable is passed through your context
@canMan656
@canMan656 5 лет назад
Hello sir, I have been following your tutorials on django and flask for some times now...I have followed this one all alongbut it seems like I have issues to create the able model city inside the database everytime I tried to add new data in the city table It shows "no such table:city " which means that the city is not inside the weather.db.I just don't know what to do,I have watched your video like 4,5 times but it seems like I am missing something...thank you!
@jimchrist-x
@jimchrist-x 4 года назад
Try using sqlite3 module instead. I believe it is faster and easier
@justinventuro2558
@justinventuro2558 5 лет назад
I am getting all of the correct json data, but the box with all the weather data on the website is not showing up. I am using pycharm, why is this???
@prettyprinted
@prettyprinted 5 лет назад
It's hard to say without seeing your code. Did you save the template in the correct place?
@justinventuro2558
@justinventuro2558 5 лет назад
@@prettyprinted Thank you for the Reply!!!! this is my first attempt at web dev so I am trying to get the app to run without SQLalchemy first. I just saved the html temp into templates in Pycharm. would there be modifications I have to do to the HTML temp (sorry, I understand the python and the Json, but not the html too well) to get the box with the weather to show
@justinventuro2558
@justinventuro2558 5 лет назад
reversed engineered your video and figured out it was the loop, it works now. But I really appreciate the fact you reply to your viewers so for that you will get a subscription!!!
@prettyprinted
@prettyprinted 5 лет назад
@@justinventuro2558 Glad you figured it out!
@technicalilm8999
@technicalilm8999 6 лет назад
how can it be uploaded to python anywhere, im having problem in connecting to database
@prettyprinted
@prettyprinted 6 лет назад
I'd have to know the specific problem.
@vaishnavi4354
@vaishnavi4354 4 года назад
Hello Actually when I added the api then it shows the error that keyerror "main".Means is shows the error in the line 'temprature':r['main']['temp'] Plz help me to re solve this keyerror
@prettyprinted
@prettyprinted 4 года назад
Check out the part 2 video.
@vaishnavi4354
@vaishnavi4354 4 года назад
@@prettyprinted Thanks a lot 👍👍
@desheen5056
@desheen5056 6 лет назад
i love your channel and your videos :) , but can you take a look at python falcon, and show it some love :) ?
@prettyprinted
@prettyprinted 6 лет назад
I'll consider Falcon.
@bwalshstudent
@bwalshstudent 6 лет назад
when I try: from flask_sqlalchemy import SQLAlchemy it gives me an error that flask_sqlalchemy is undefined even though I pip installed it and it says that it is there. Any recommendations?
@prettyprinted
@prettyprinted 6 лет назад
Are you sure it's install in the environment you're using to run the code?
@bwalshstudent
@bwalshstudent 6 лет назад
Pretty Printed yeah: I imported all my other libraries there. The app runs and works, it just in my VSCode editor gives me the error. Should I just ignore it if it works?
@prettyprinted
@prettyprinted 6 лет назад
Yeah, I'd just ignore it.
@sammwangi7565
@sammwangi7565 6 лет назад
make a virtual environment and run it from there `virtualenv venv` later navigate into it by typing `source venv/Scripts/activate` and then later pip install the packages
@lilredbb2182
@lilredbb2182 4 года назад
i cant do this in windows,,,,,,,sad
@El-barto1
@El-barto1 Год назад
how to get the api it aint free?
@prettyprinted
@prettyprinted Год назад
You should still be at to get a free API by going to openweathermap.org
@owaisahmed7952
@owaisahmed7952 4 года назад
At 14:09 its nullable=False
@natalieandrade1558
@natalieandrade1558 3 года назад
sqlite3 weather.db????
@IsItTimeToTravel
@IsItTimeToTravel 6 лет назад
Good Job. Now how can we make these cities auto update themselves ?
@ankushsarkar1746
@ankushsarkar1746 6 лет назад
Every time u visit the web site it will get the weather from the api so it gets updated. He did not store the weather in the data base.
@jimchrist-x
@jimchrist-x 4 года назад
@@ankushsarkar1746 maybe what he was trying to say was how to refresh the page automatically. For this you must use database or else use the meta tag for auto refresh in your html file.
@Shortsodia1
@Shortsodia1 2 года назад
Why you guys making video.did you check back your video quality . nothing showing in clear . disgusting
@MylesGmail
@MylesGmail 5 лет назад
ty i tweeted this
@prettyprinted
@prettyprinted 5 лет назад
Thanks!
Далее
Find The Real MrBeast, Win $10,000
00:37
Просмотров 22 млн
Updating the Flask Weather App [Part 2]
30:48
Просмотров 10 тыс.
How to Build a Weather App with Python | Weather API
8:36
Build APIs with Flask (the right way)
49:09
Просмотров 11 тыс.
The Value of Source Code
17:46
Просмотров 82 тыс.
I Remade YouTube From Scratch Using Just Bash
17:51
Просмотров 23 тыс.
Python REST API Tutorial - Building a Flask REST API
1:14:01