Deploy Flask App With Database On Heroku For Webhosting - Flask Fridays #39

  Рет қаралды 31,829

Codemy.com

Codemy.com

Күн бұрын

In this video I'll show you how to deploy your app to Heroku for professional webhosting.
Up until now we've been working on our app locally on our own computer. Now we want to push the code to webhosting to make the app live online.
We'll be using the free version of Heroku to host the app.
#flask #codemy #JohnElder
Timecodes
0:00​​ - Introduction
0:58 - Rename App to app.py
1:36 - Download Heroku Toolbelt CLI
2:40 - Pip Install Gunicorn
3:16 - Pip Install Postgres Psycopg2
3:38 - Create Requirements.txt File
4:13 - Create Procfile
5:12 - Login To Heroku From The Terminal
6:05 - Create Heroku App
6:55 - Create Database On Heroku
7:44 - Get Database URL And Add To app.py
8:42 - Remove Character Count From Text Field In Model
9:05 - Save Code To Git
9:25 - Push Code To Heroku
10:43 - Migrate Database On Heroku
11:42 - Conclusion

Пікірлер: 110
@Codemycom
@Codemycom 2 жыл бұрын
▶️ Watch Entire Flask Friday Playlist ✅ Subscribe To My KZbin Channel: bit.ly/3ig2eJn bit.ly/2IGzvOR ▶️ See More At: ✅ Join My Facebook Group: Codemy.com bit.ly/2GFmOBz ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt! Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN ▶️ Get The Code bit.ly/2L1jBl5
@stephanecomeau9414
@stephanecomeau9414 2 жыл бұрын
I had been banging my head against the wall for hours trying to host my web app on Heroku. Thank you so much for putting up this video....I just wish I had found it earlier!
@Codemycom
@Codemycom 2 жыл бұрын
Glad you got it sorted out!
@akhilpandey
@akhilpandey 2 жыл бұрын
Thanks man! I really needed a comprehensive tutorial on hosting a Flask app on heroku. Thank you very much! : )
@faithikhidero6085
@faithikhidero6085 2 жыл бұрын
This tutorial just did the magic! I've been able to deploy my flask app on heroku, thank you!
@Codemycom
@Codemycom 2 жыл бұрын
Happy to hear it!
@alionurtepeciklioglu9083
@alionurtepeciklioglu9083 2 жыл бұрын
Thank you very much for all the series!!
@Codemycom
@Codemycom 2 жыл бұрын
Glad you like them!
@nimrodshefi2046
@nimrodshefi2046 Жыл бұрын
with heroku cancelling the free version a few months ago, which cloud service do you recommend to use?
@artcodezen
@artcodezen 2 жыл бұрын
Nice very nice explanation! 😁
@lator1941
@lator1941 2 жыл бұрын
most of the resources i find are using bash shell. isn't there a way to use powershell on Windows to do these things?
@andrewschneider5722
@andrewschneider5722 7 ай бұрын
How would you handle using dotenv for managing keys for API's? Can't upload the env file to git so how do we make a env file available to the heroku app?
@zdravkojovancevic4591
@zdravkojovancevic4591 2 жыл бұрын
I have one more question.. How to hide your app.config['SECRET_KEY'] when pushing to the GitHub?
@falconeight480
@falconeight480 Жыл бұрын
7:37 is what I've been looking for thank you
@Codemycom
@Codemycom Жыл бұрын
Happy to help!
@rastaricky9584
@rastaricky9584 7 ай бұрын
Excellent video…like how you went straight to the point…ne subscriber❤
@Codemycom
@Codemycom 7 ай бұрын
Thanks!
@ETF-DEATH
@ETF-DEATH 2 жыл бұрын
Thank you for the amazing videos!
@Codemycom
@Codemycom 2 жыл бұрын
Very welcome!
@rob5820
@rob5820 2 жыл бұрын
My db is in my __init__ file within the website folder. app.py is outside the website folder. How do I import the db in that case? "from website import db" isnt working.
@BugMonsters
@BugMonsters Жыл бұрын
Awesome Video. What do I do if I need to update the database on heroku. Can I acess it from my local machine and run ETL routines from it?
@lotosvideos9101
@lotosvideos9101 2 жыл бұрын
Your videos are really helpful for my current project... Thanks! It would be cool if you do video on how to create a chat app in Flask website.
@Codemycom
@Codemycom 2 жыл бұрын
Good suggestion :-)
@lucasbcardoso
@lucasbcardoso Жыл бұрын
I'm getting the error dash.exceptions.DependencyException: Error loading dependency. "dash" is not a registered library. can you help? i've reinstalled dash and the problem continues...
@InfoTusi
@InfoTusi 2 ай бұрын
How do I copy all the info from my sqlite db file to the heroku postgres database?
@alexgreen8231
@alexgreen8231 5 ай бұрын
Thank you, great video!
@Codemycom
@Codemycom 5 ай бұрын
Welcome!
@some_dude1
@some_dude1 Жыл бұрын
Hi man! Nice video. But when I in get bash on heroku login press enter it just freezes and nothing hapening? Why is that? Anyone guys have this problem?
@saurabhmhatre1314
@saurabhmhatre1314 2 жыл бұрын
Thank you So Much ! really helped me a lot :))))
@Codemycom
@Codemycom 2 жыл бұрын
Happy to hear it!
@mui_bikash
@mui_bikash 2 жыл бұрын
Thank you. Appreciated :)
@Codemycom
@Codemycom 2 жыл бұрын
Sure thing
@ecgisamal
@ecgisamal 2 жыл бұрын
Thanks a lot!
@albertusschrier7867
@albertusschrier7867 Жыл бұрын
I couldn't get this to work, but whatever because I saw your video "Heroku Decided To Screw Over All Coding Students!".
@salilmarathponmadom7255
@salilmarathponmadom7255 2 жыл бұрын
Great one !!
@Codemycom
@Codemycom 2 жыл бұрын
Thanks!
@leogovan5076
@leogovan5076 2 жыл бұрын
Great video - if you have your app.py in a sub folder like /backend how do you point to that correctly in the Procfile if that is in the root folder? Is it something like "web: gunicorn app:backend/app"?
@craftapple9446
@craftapple9446 5 ай бұрын
Up
@denisgarden1
@denisgarden1 2 жыл бұрын
Hello, John! I have a problem. In the terminal all looked good, but when I went to browser I got an error message under my Heroki app url: "Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail". How to fix it?
@Codemycom
@Codemycom 2 жыл бұрын
Do what the error says. From the terminal: heroku logs --tail
@constantiniasmin4554
@constantiniasmin4554 2 жыл бұрын
Hello, I'm trying to deploy a complex flask app, build with factory pattern and I have some problem due to the interpreter paths. Locally from PyCharm IDE, I can set them manually, but how can I do something similar from Heroku, or maybe from code? Thank you in advance!!!
@Codemycom
@Codemycom 2 жыл бұрын
No clue, I don't use Pycharm and recommend that no one else use it either...this is just another reason why.
@wohu1
@wohu1 2 жыл бұрын
hi I really like this video! Now I am working on my side. One question I am wondering is, if we already have a database in sqlite, how can we use this current database instead of creating a new one?
@Codemycom
@Codemycom 2 жыл бұрын
I don't have any videos on that, and you definitely wouldn't ever want to use sqlite for production
@nezhatnour2462
@nezhatnour2462 2 жыл бұрын
Thank you for this video. How to paste that code for my Django setting. I do not have app.config! Where do I suppose to put the code?
@Codemycom
@Codemycom 2 жыл бұрын
You have to just follow the directions in the video.
@swaroopv5229
@swaroopv5229 2 жыл бұрын
All are explain about heroku only. How to deploy in cpanel with database please make a video i tried so many times but i ended up with irrelevant tutorials. I hope i will get solution here
@dionnamorris6367
@dionnamorris6367 2 жыл бұрын
Hi John! I came across your website and I’m looking to join. I want to eventually become a ROR developer, but first want to learn Ruby before getting into ROR. I am just wondering which Ruby course of yours you’d recommend me to start with - Intro to Ruby Programming or Ruby Programming For Everyone?
@Codemycom
@Codemycom 2 жыл бұрын
Either one, they're very similar. Try Ruby for Everyone.
@realgamer8497
@realgamer8497 2 жыл бұрын
i am having a flask python app with cv2 dlib libraries in it from ML models. But there is application error and its showing different errors everytime. Is this the same process for such (ML - dlib - opencv) based apps as well? And since it is having dlib and tensorflow the slug size exceeds as well
@Codemycom
@Codemycom 2 жыл бұрын
Should be. Give it a try and see
@rutwikpatil8491
@rutwikpatil8491 2 жыл бұрын
If you want to deploy DL,CNN model I suggest you go for paid plans or AWS. I have faced this issue with Pytorch, use CPU packages only; Optimise imports, and use lower version packages. This gelped me reduce my slug size from 1.1GB to 480MB. But the real issue is when it loads up. My App RAM usage was 1.4 GB and it was impossible to optimise it. It will crash and exit in heroku free version. Hope this helps.
@swapnilsapre8478
@swapnilsapre8478 2 жыл бұрын
@@rutwikpatil8491 thanks. I will try
@evil.corporate
@evil.corporate Жыл бұрын
it is saying 'from' isnt a bash command, when i try to import app to db, what is wrong?
@Codemycom
@Codemycom Жыл бұрын
Why would you ever type in "from" into the bash terminal? I think you forgot to first enter the python shell.
@farazrasool2753
@farazrasool2753 2 жыл бұрын
HELLO SIR, I AM MAKING A SERIOUS PROJECT ON FLASK..RIGHT NOW GOT STUCK ON A PROBLEM . CAN YOU PLEASE HELP ME. I HAVE TRIED MANY( A LOT) PEOPLE TO COMMUNICATE MY PROBLEM BUT NONE OF THEM CAN'T SOLVE THAT PROBLEM. THE PROBLEM IS VERY LITTLE BUT AS A LEARNER I DON'T KNOW HOW TO MAKE IT RIGHT. SIR IT WOULD BE GLAD IF YOU HELP ME
@alexi2706
@alexi2706 Жыл бұрын
Heroku new update states that they do not offer Postgres free of charge anymore. What are your thoughts? Should I go with one of their plans or look for something else? (P.S. I am new to Heroku and I don't know what to expect)
@Codemycom
@Codemycom Жыл бұрын
Yes, it's no longer free...I don't yet have a free alternative.
@sjwang3892
@sjwang3892 Жыл бұрын
Thanks a lot for you video! Super helpful. What do I do if I want to populate the database on the webserver? For example there are some pre-existing users that should be ready to query when the app is created. In local environment I do session.add and session.commit in the flask shell but not sure where to do it in webhosting. Could you please give some guidance?
@sjwang3892
@sjwang3892 Жыл бұрын
Guess the questions is more about how to copy data from local sqlite database to production heroku postgres db. Would appreciate any help!
@Codemycom
@Codemycom Жыл бұрын
Sorry, I don't have any videos on that.
@sirishareddygumpu9666
@sirishareddygumpu9666 2 жыл бұрын
Hello sir actually i am using sql database with python using flask ,I am getting bad request The browser (or proxy) sent a request that this server could not understand. Can you please help with this pleaseee....😥
@Codemycom
@Codemycom 2 жыл бұрын
You'll have to google the error
@mohammadrajha5181
@mohammadrajha5181 2 жыл бұрын
how i can download git to work git add . in terminal on windows 10
@Codemycom
@Codemycom 2 жыл бұрын
git-scm.com/download
@aditya.21
@aditya.21 Жыл бұрын
Hey! John, How's it going for you? I am a student and basically do not have a credit card yet, because I don't earn enough. What can be an option to this?
@Codemycom
@Codemycom Жыл бұрын
Paypal? Parent's card?
@eromoseleedeko3839
@eromoseleedeko3839 Ай бұрын
Hi John thsnks for the video, but what if i want to use a domain i bought from say namecheap or godaddy
@Codemycom
@Codemycom Ай бұрын
Go to settings in heroku and enter it there where they ask for it.
@silaskanku7377
@silaskanku7377 9 ай бұрын
How do i connect heroku postgresql in django project
@Codemycom
@Codemycom 9 ай бұрын
this is a flask video
@icecube721
@icecube721 2 жыл бұрын
hello there. Thank you for the video. I have a question about db.create_all(). My db is initiated under /website/__init__.py file. I tried "from website import db" then db.create_all(). Then I get this Runtimeerror: No application found. Can you please help? thank you!
@Codemycom
@Codemycom 2 жыл бұрын
what did you do differently from the video?
@icecube721
@icecube721 2 жыл бұрын
@@Codemycom I followed the steps in the video exactly. The only difference is that my app and db is created under /website/__init__.py file instead of the app.py file under the main folder.
@Codemycom
@Codemycom 2 жыл бұрын
@@icecube721 then you didn't follow the steps in the video exactly
@legendanmify
@legendanmify 2 жыл бұрын
have you figured it out? if you haven't yet and if you followed another tutorial for a notes website, you don't need to do the db.create_all() at all. once you've deployed it to heroku, the db is already created and set up. the issue is with sqlalchemy only able to handle postgresql
@rob5820
@rob5820 2 жыл бұрын
I have the same issue. I too modulated the project so its split into small er files rather than the entire app in one app.py file. It should be possible but I cant figure it out, if you find the solution please share it. Thanks!
@royalgranitecountertops331
@royalgranitecountertops331 Жыл бұрын
Can an Web app, using Phyton, flask, database, and ionosphere eb hosting
@Codemycom
@Codemycom Жыл бұрын
can it be what?
@MirasLaptop
@MirasLaptop 5 ай бұрын
will it work if use mysql not sqlalchemy?
@Codemycom
@Codemycom 5 ай бұрын
Not without changes
@cmputerprgrammer7800
@cmputerprgrammer7800 2 жыл бұрын
*Sir, please teach Go programming language. And host its website on heroku. It very easy and very very speed (go is as speed as C++).*
@Codemycom
@Codemycom 2 жыл бұрын
Might do that at some point
@ThelioAi
@ThelioAi Жыл бұрын
do you have a similar video for flask and mysql?
@Codemycom
@Codemycom Жыл бұрын
No, but why would you want to use Mysql?
@juandiegomatute4333
@juandiegomatute4333 7 ай бұрын
​@@CodemycomHello, i wondering the same question. I always use MySQL, so I would like to use again, Is posible or not? Thanks
@codeKeshav
@codeKeshav 2 жыл бұрын
Sir John, Make a tutorial video that show *how to push/collect the byte stream of any image which is set as Pixmap Image of any label in PyQt5 Programs to database like postgress using just python*
@Codemycom
@Codemycom 2 жыл бұрын
Uh, no lol
@K3vyB
@K3vyB 2 жыл бұрын
lol yes
@codeKeshav
@codeKeshav 2 жыл бұрын
@@K3vyB say crearly
@GCRickerNH
@GCRickerNH 2 жыл бұрын
SQLAlchemy 1.4 doesn't work directly with Heroku. You will get the error, "sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres" when you try to create the database. The easiest solution is to pip uninstall SQLAlchemy 1.4 and redo with a pip install SQLAlchemy ==1.3.23
@wnywebdevelopment8757
@wnywebdevelopment8757 2 жыл бұрын
To fix this, rename postgres:// in the URL to postgresql://
@MetaFisica.
@MetaFisica. 2 жыл бұрын
it's not working for me
@twiincentral8780
@twiincentral8780 Жыл бұрын
@@wnywebdevelopment8757 just for anyone else: this suggestion to change the name to ‘postgresql’ in app worked for me. Thank you!
@some_dude1
@some_dude1 Жыл бұрын
@@MetaFisica. me too :(
@homosapien5002
@homosapien5002 2 жыл бұрын
can we visit the website sir?
@Codemycom
@Codemycom 2 жыл бұрын
Of course, why couldn't you?
@fauzikurniwan3835
@fauzikurniwan3835 9 ай бұрын
Is it fully free? Can i still use it if i dont have credit card?
@Codemycom
@Codemycom 9 ай бұрын
No
@skyline-wd3gr
@skyline-wd3gr 2 жыл бұрын
You are from which country
@Codemycom
@Codemycom 2 жыл бұрын
United States
@skyline-wd3gr
@skyline-wd3gr 2 жыл бұрын
Upload videos on sql database
@Codemycom
@Codemycom 2 жыл бұрын
Already have a course on sql database at Codemy.com
@CrystalCloudPodcast
@CrystalCloudPodcast Жыл бұрын
42
@ghostpet
@ghostpet 3 ай бұрын
If your server doesn't work you my need to change the db url postgres:// to postgresql://.
Only Delete Correct User - Flask Fridays #40
5:48
Codemy.com
Рет қаралды 4,2 М.
Heroku Is Dead, Here's What I Recommend
11:59
Theo - t3․gg
Рет қаралды 252 М.
КАК ДУМАЕТЕ КТО ВЫЙГРАЕТ😂
00:29
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 6 МЛН
Deploy your Flask app on Google Cloud Platform
17:51
Leslie Wubbel
Рет қаралды 13 М.
How to Deploy a Flask App and Postgres Database to Render
16:39
Pretty Printed
Рет қаралды 44 М.
Push Flask Apps To Heroku For Webhosting - Python and Flask #11
10:54
Deploy a Flask Application on Heroku
15:13
Real Python
Рет қаралды 14 М.
Simple Web App with Flask and Heroku - Python GUI for Beginners
25:07
Python Simplified
Рет қаралды 218 М.
Best Platforms to Host Python Apps (for free!!)
9:50
Patrick Loeber
Рет қаралды 112 М.
Railyway is The New Heroku
8:43
NeuralNine
Рет қаралды 17 М.
Deploy Flask Web App on AWS Elastic Beanstalk|
10:31
Nachiketa Hebbar
Рет қаралды 39 М.