"Web App" Exercise
Last updated
Was this helpful?
Last updated
Was this helpful?
Create a basic web application in Python, using modular architecture.
Write routing logic to handle GET and POST requests, and respond by rendering HTML pages or returning JSON data.
Gain exposure to HTML templates, and using HTML forms to submit form data.
Run a web application in "development" using a local web server, and deploy to a user-facing "production" environment (i.e. a Heroku server).
To use the Flask package, let's first add Flask
to the Daily Briefing repo's "requirements.txt" file, then re-install packages:
Now follow these sequential "checkpoints" for a guided walk-through of how to create a Flask application:
Reference:
After completing all the checkpoints and demonstrating the ability to successfully run the web app locally, let's re-deploy the source code:
Heroku says "no web process specified". They want us to create a specific file called the "Procfile" in the repo's root directory to instruct the Heroku server which command to invoke in order to run the web app:
Since we're instructing the server to use the "gunicorn" package (Heroku's preferred tool) to run the web app on production, we'll also need to add gunicorn
to the "requirements.txt" file so it will be installed on the server during the deployment process.
After saving the "Procfile" and "requirements.txt" files, make a commit before re-attempting to re-deploy:
View the server logs and troubleshoot as necessary:
So, you've to send you an email every day. But what if you wanted the information on-demand at the click of a button, without waiting for the next daily email? And what if you wanted to allow other people to register for your service? Let's build a web application interface into your application's functionality!