Lab 8: Introduction to
Web Applications

Part 6: Deploy Repl from Step 4 on Heroku

Now, we'll take the repl from Step 4, the one where we added a navbar using Bootstrap, and we'll deploy it to Heroku.

Step 1: Fork your repl from Part 4 and add to README.md

At the end of Part 4, you put a link to your Repl in the README.md file of your lab08-name1-name2 repo.

Now , go back to that README.md, click on the link to the repl for Part 4, and fork it.

We'll use this forked copy for Part 6.

Add a link to this repl in the README.md under a heading # Part 6

Step 2: Deploy this app to Heroku

To deploy this app to Heroku, you'll follow the same steps as in Part 5, staring with Step 4.
Here's a summary:

  1. Install the Heroku CLI into your repl, by typing heroku -v in the Shell window.

  2. Login to Heroku using heroku login -i

  3. Choose an app name for Heroku: we suggest a name such as:
    lab08-name1-name2
    spis2022-lab08-xy (where xy are the initials of the first names of the pair partners)
    spis2022-lab08-xyz (where xyz are the initials of the first names of the three members of the trio)

  4. In the shell window, type this (where app-name is the name you chose above)
    git init
    heroku create
    app-name

  5. Install gunicorn by typing this in the Shell window:
    python3 -m poetry add gunicorn

  6. Add a Procfile with these contents:
    web: gunicorn main:app --log-file=-

  7. Add an app.json file with these contents:
    {

"buildpacks": [

{ "url": "https://github.com/moneymeets/python-poetry-buildpack.git"},

{ "url": "heroku/python" }

]
}

  1. In pyproject.toml, change the Locate these two lines:

    [tool.poetry.dependencies]
    python = ">=3.8.0,<3.9"


    Change them to this:

    [tool.poetry.dependencies]
    python = "3.10.6"

  2. Make a commit (Making commits to repo via repl.it)

  3. Type git remote -v to make sure there's a remote hooked up to the repl; you should see one called heroku
    (if not, there aretroubleshooting instructions in Part 5)

  4. Type git push heroku main to deploy your application.

  5. Open the URL shown in a browser to test your deployment.

Step 3: Make sure the app works properly

If not, see the details in Part 5 for hints on how to debug.

Step 4: THE FINAL STEP

In your lab08-name1-name2 repo, in the README.md, add a heading

# Part 6

And under that, put a link to your repl for the Hello World app that you deployed to Heroku, along with the URL of the deployed app on Heroku.

And you are finished with lab08!

Final Thoughts

Granted: there is a lot of tedious work getting started with building a web app.

However, once you've gotten past these stages, there are so many very cool things you can build.

And the cool part about building a web app is that you can share it with anyone in the world, and show off your work!