Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 2.98 KB

deploy-to-heroku.md

File metadata and controls

55 lines (37 loc) · 2.98 KB

Deploying your app to Heroku - a step by step guide

Up until now, we have been working on our app and running it locally on our laptops. Whilst this is useful for testing out our app during development, it's no good if our friends want to see what we've done in this course!

In order for our friends to see the app, we need to upload (deploy) our code to Heroku, a cloud-based platform which will assign a publicly accessible URL to our app that can then be visited!

Without further ado, let's go through how you can deploy your first app to Heroku!

  1. If you haven't already, go make a Heroku account at https://www.heroku.com

  2. Once you have made a Heroku account, upon logging in, you will be taken to a dashboard, which looks something like the following:

alt text

  1. To deploy the app, we need to make one first on Heroku, so do that by clicking New > Create New app (button at top right of the dashboard)

  2. Type in the name of your application, and change the Runtime Selection to "Europe" - this is so that the application loads faster as we are geographically closer to Europe than the United States. Finally, click "Create App".

alt text

  1. After clicking "Create App", you should be greeted with the following screen:

alt text

  1. Under "Deployment Method", change it to "GitHub". A "Connect to GitHub" section should now appear.

  2. Under the "Connect to GitHub" section that just appeared, search for the GitHub repository corresponding to your project, then click "Connect" to link the relevant repository (appeared as a result of the search) to the Heroku application you've just created.

  3. To deploy your project, click "Deploy Branch" under "Manual deploy".

  4. (Optional) You may have just noticed that a section named "Automatic deploys" has appeared in addition to the "Manual deploy" section once you have connected your GitHub repository properly. To save you having to come back to this page in the future and click "Deploy Branch" each time you pushed something new to your repository, if you click "Enable Automatic Deploys", then Heroku will do so automatically.

Congratulations! You have now successfully deployed your application to Heroku!

Adding new Python libraries to your app

When developing our apps locally, if you want to use a Python library like Flask in order to start up a server controllable by you, the library needs to be installed first before we can use it by running pip install Flask (or replace Flask with whatever library you need to install in that command).

Luckily, you don't have to do that explicitly when the app is deployed onto Heroku as the library installation process is all managed for us by Heroku. To add a new library to your app, update the requirements.txt file by writing in the name of the library on a new line, after the three libraries I've set up for you already in the start point code.