Django app on Heroku, deployed successfully but could not be served - python

I have built a simple blog app with Django by following a video and deployed it to Heroku by following another video.
The app works fine locally, but it is not working online.
Heroku gives me this error message:
This app has no process types yet
Add a Procfile to your app in order to define its process types.
I had already added a Proclife created with Notepad with these contents:
web: gunicorn mysite.wsgi
But how can I add another Procfile to an app already deployed to Heroku?
Where should I place it?

Yeah that's correct. It required file 'Procfile' in the project root directory. I have created one with below content
web: gunicorn <your-app.wsgi> -b 0.0.0.0:$PORT -w 10
And followed the below link https://devcenter.heroku.com/articles/procfile where everything is mentioned to deploy the code to heroku.
Its been long time for me working with heroku that too with test app so I am not sure if it got changed after that. But I think just following the link will work just fine.

Related

Deploying Python FastAPI to AWS Beanstalk

I have a small python FastAPI project which is completely working on my local computer. But when I try to deploy it to AWS Beanstalk (manually for now) I've always got a '502 Bad Gateway' error when open the application in a browser.
This is my project structure:
/project
/html/
main.py
Procfile
requirements.txt
the main.py contains the api endpoints that use some HTML files. These files are in the html/ folder.
The Procfile looks like this:
web: uvicorn main:app --host 0.0.0.0 --port 80
and the requirements.txt like this:
fastapi~=0.91.0
uvicorn
When I uploaded an example application from AWS to the same Beanstalk environment, it worked. And as I said, even if I execute the python project locally, it works fine. So I must have configured something wrong.
Does anybody know this problem and know how to fix it?
Found this useful guide that solved my problem: https://testdriven.io/blog/fastapi-elastic-beanstalk/.
Maybe there is someone who needs it.

Difficulty in deploying ML model to Heroku

Any help would be much appreciated. I created a repository here where all files are linked. I'm currently trying to learn how to deploy an ML model to Heroku. This is a pretty simple model and I was following along with a YouTube tutorial. When I run 'python app.py' on my terminal, the local server does run correctly, showing the exact interface I want.
When trying to deploy it on Heroku, I linked my GitHub repository and selected 'Deploy Branch'; Here, Heroku states that the app was successfully deployed. HOWEVER, when I then try to view, a page comes up stating Application Error.
As mentioned, I'm really not sure what's going wrong and would appreciate any guidance to get this working – I'd like to deploy other ML models I've been working on and getting this preliminary one running would be a huge help. Any advice?
Thanks!
It seems like you have forgotten to create the Procfile. This is necessary for Heroku as it tells Heroku how to startup your application on it's servers.
Since you're server file is app.py and the Flask app is app as well, the following would be the contents of the Procfile
web: gunicorn app:app
Also update your requirements.txt file by adding gunicorn, as an example what i had was
gunicorn==20.1.0
For more information about the Procfile see https://devcenter.heroku.com/articles/procfile
I have deployed this personally and it works fine now 😁

How to run python apps using Procefile on heroku

I've deployed my app on Heroku and run dyno. By default it searches for main.py module and runs it, but I want to specify the folder and app to run. How can I do this?
This is how it's normally works by default
But I want to run app from the "app" folder as it illustrated in the picture
in Procfile we can include our processes and name them as it show in code below
proc_name: python folder_name/app_name.py
And run it on Heroku CLI
heroku ps:scale proc_name=1

My Python Flask-SocketIO webapp is not running on Heroku

I'm having some troubles deploying this app on Heroku. The code is on a folder, where i created a git using git init, added everything to my git and then pushed everything to Heroku before running it.
I generated my requirements.txtand my procfile looks like this:
test: python "application.py" heroku ps:scale web=1
But on my webpage nothing will load, i'm assuming because i'm only running the Python part. How can i deploy it so that Heroku will know to run not only my Python script, but also the frontend part with the javascript and index.html files?
For development, you can serve static files with Flask.
For production, use cloud CDN (like Amazon's or Google's) or add a web-server to your app (Nginx or Apache or whatever).

'Coudn't find that formation' error when adding web dynos to Heroku flask app?

I've just installed flask and heroku, and despite not having a problem with creating a simple app, now i download .zip file with ready code i wanted add and run this app on my heroku profile.
I get following error:
heroku ps:scale web=1
Scaling dynos... failed
! Couldn't find that formation.
Procfile:
web: gunicorn nameapp:app --log-file -
As you've anticipated, this almost certainly relates to your Procfile. Some obvious ones to check first (quoting Heroku.com):
A Procfile is a file named Procfile. It should be named Procfile exactly, and not anything else. For example, Procfile.txt is not valid. The file should be a simple text file. The file must be placed in the root directory of your application. It will not function if placed in a subdirectory.
If this doesn't help, it's possible that your Procfile is being ignored by git. See a similar question here: How to overcome 'Coudn't find that formation' error when adding web dynos to Heroku django app?

Categories

Resources