Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Tom Finet
Tom Finet
7,027 Points

Built the flask API, how do I deploy it to heroku?

I have finished the flask API and want to know how I can use this to get data for a flask website. I have tried to deploy to heroku and have successfully but when I load the url that my code is located at I get the following message in my web browser:

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.

How do I deploy my app to heroku. I have created a new app which only contains the app.py file and it deployed fine. I followed this tutorial: https://www.youtube.com/watch?v=pmRT8QQLIqk.

If anyone is willing to help I can share my code with them privately so that they can give me a hand and locate the bugs.

Email me at tomfinet.work@gmail.com, if you want to help out.

Thanks

Tom

4 Answers

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hello Tom. I have used Heroku together with Flask a couple of times, I may be able to help.

First thing that might be useful: can you post the code in your requirements.txt file and in the Procfile? Also, I presume that the app does not have a database connected as it is a single file application, right?

Thanks, Vittorio

Peter Javorkai
Peter Javorkai
31,477 Points

Hi Vittorio Somaschini! Can you recommend some general resource on deploying flask apps on Heroku, because I've tried the requirements.txt and Procfile updates as well, but still not detecting the buildpack. I've tried to upload the Bear builder from the Flask track as a practice how this process goes but I couldn't find it out till now. Thanks in advance!

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hi Peter Javorkai !

Would you mind starting a new thread posting more details so that we can discuss the issue there?

I have used flask a few times and I did not find major issues, but maybe your application needs something specific. You can probably include the file structure of your your project, and all the relevant info. I think that would help ;)

;) Vittorio

Peter Javorkai
Peter Javorkai
31,477 Points

Thanks Vittorio Somaschini I have another idea let me try that, and then if that fails I'll return. :)

Peter Javorkai
Peter Javorkai
31,477 Points

Actually do you have some kind of step by step guide? Maybe that would be beneficial to check that first, I've tried the general guidance of Heroku, but that didn't work https://devcenter.heroku.com/articles/getting-started-with-python#introduction

Vittorio Somaschini
Vittorio Somaschini
33,371 Points

Hi Peter.

I do not have a tutorial to recommend, the guide at the link that you provided worked for me. But I believe there will be plenty of video tutorials here and there on the internet...

Vittorio