Prompt for Jan. 29

Today we're going to look at how to deploy applications to the web so that others can view them. The goal here is not to create a production-ready system. While we'll incorporate some libraries that are highly performant, we won't be following the absolute best practices for industry use so that we can instead make things a bit easier to prototype.

Requirements: Python 3 | Flask | WhiteNoise | Gunicorn | free Render account | GitHub account (recommended)
(you can use pip to install "flask" and "whitenoise")

A number of cloud "platform as a service" tools exist for hosting web-based projects efficiently. In short, they allow you to upload web server code to a cloud backend which then does the hard part of making them web-accessible. While today we will make use of Render, there are many different providers. These include (in no particular order) Microsoft Azure, AWS, Railway, Fly.io, and Digital Ocean among many others. I encourage you to examine each and figure out which set of features and end-user agreement works best for you. For the purposes of this class, you should not need a paid account.

Important note: You may not need a full Render web service to host a basic homework project. While I am demoing a full web service today, check out Render's ability to serve static sites which will likely suffice for HW1, HW2, etc.

Our system will involve the following components:

At the conclusion of the class, you'll be able to find the files we used here. You can access the Render site we created here.

Commands used in the lecture:

      
      # Go on GitHub and make a new project for your code
      #  (you can also add collaborators at this time)
      
      # Clone your repository on your computer
      git clone -REPOSITORY URL-
      
      # Render needs a requirements file
      #  Use a text editor of your choice. I use Atom, which can run from the command line
      atom requirements.txt
      
      # It includes:
      #   gunicorn - library that runs our code as a web service, must include
      #   flask - imported in our .py
      #   whitenoise - imported in our .py
      
      # Verify that you have installed all of the libraries you are requiring
      pip install -r requirements.txt
      
      # Make a Flask app (make sure Python 3, Flask, and WhiteNoise are installed)
      atom app.py
      
      # See the demo files for what we added to app.py

      # At this point we also made a static directory and put some files in it for Whitenoise to serve

      # Test Flask server to see if it works (command may just be python for your machine)
      python app.py
      
      # Commit the changes to your local git repository
      git status
      git add app.py
      git add requirements.txt
      # etc. to add all changed/added files

      # Now commit the changes and push to Github
      git commit -m "first commit"
      git push

      # You now need to set up a project on Render. If is easiest if you connect your account
      # Pick Web Services from the list and select your repository
      
      # Render usually figures out what kind of service you need, but it may get settings wrong
      # Make sure you have set:
      #   Python or Python 3.7 for Environment
      #   pip install -r requirements.txt in Build Command
      #   gunicorn app:app in Start Command

      # Once you create your page, it will begin to build. Check the page for errors/logs
      
      # If you want to modify your page, commit the changes to your repository
      # Then just use the Render menu to pull from your latest commit to update and rebuild