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).
Related
I am building a web app with a Flask backend and a React front end, and I would now like to deploy it, buy a domain, and set it up. What is the easiest way to do this?
Here's my research:
This website shows how to deploy an app on Heroku. I did this, but Heroku seems to be unavailable a lot, at least today.
This blog post seems to suggest I could create a GCE instance and run things there, though (i) it seems like a little more configuration that I'd like (ii) I would need a way to link the nginx server to my domain. I suppose the benefit is that the two apps run on the same machine?
This SO post had OP redo his work and it somehow worked. I'm not sure how to deploy Docker apps online, though.
Is there an easy way to deploy to a reliable service (Google Cloud/AWS/Azure)? My code has the following structure:
build/ # Result of `yarn build`
server/
server.py # Flask server
src/ # React code
Component/
Component.js
Component.sass
index.css
index.js
...
public/
index.html
# Images and other stuff.
I figured out how to do this using Azure. I created an App Service, then installed the Azure Tools VS Code extension. You need to move the Python server to the root directory and rename it to app.py (so the .env is also in the root folder), and then you can right-click your App Service in VS Code (in the Azure Tools tab) and then click Deploy to Web App. Easy!
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
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.
I'm trying to deploy a python-based scientific application on IBM's bluemix platform. However, while I can launch the cgi services to host the web pages, the python application behind it doesn't currently run. The application currently runs on an apache server on rackspace, but I'm try trying launch a newer version for testing. I tried Heroku, with the same problem that the web pages will be served, but not the python application. But the heroku gist seems to be that Heroku can't serve cgi applications. And there was a suggestion that the Cloud Foundry platform would be able to do so. The application runs fine locally, so I'm trying to find the right tweak to deploy to Bluemix (or Heroku).
We have the requirements file, and the initial thought is that it's the procfile that needs tweaking. Currently it looks like:
web: python -m CGIHTTPServer $PORT
I've tried launching the application via the worker tag.
worker: python weblogo.py
worker: python setup.py
even trying to launch the internal files:
worker: python /weblogolib/_cgi.py
worker: python /weblogolib/__init__.py
Yet none of these methods worked on getting the application behind the web pages to work. Is there another method that we're unaware of?
The application is designed to be served locally with the command.
python ./weblogo --serve
Does this matter when deploying to a cloud platform?
Rewriting the application to Flask or Django isn't really an option now. Any guidance toward the getting the application launched would be much appreciated! Thank you in advance!
I recently made some changes to the structure of my Flask app hosted on heroku and now heroku has decided to detect it as a Node.js app intead of a Python app. My application uses both python (Flask) for the backend api and javascript for the front end.
The changes I made included integrating npm and bower into my application to streamline the javascript development of the app.
The problem was introduced when I added a package.json to my root directory when I started using npm. It seems that the build detection script runs the nodejs detection first (here) which leads to this code: if [ -f $1/package.json ]; then
echo "Node.js" && exit 0 executing and Heroku thinks it's a nodejs app and exits before the python detection has a chance to run.
To solve this I had to manually tell Heroku that I wanted a python build using this command
heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python.
The package.json file is causing Heroku to detect it as a node.js app. To prevent this, add the file name to a .slugignore file:
echo 'package.json' >> .slugignore
git add .slugignore
.slugignore is like .gitignore. It resides in the root directory of your repository and should contain a list of filenames and wildcard patterns. The matching files remain in your git repository, but are deleted from the slug after you push to Heroku. The deletion occurs before the buildpacks run, so the node.js buildpack won't find package.json and the app won't be misidentified as a node.js app.