➡️ Slides
- [5m] Objectives
- [10m] Overview: Environments
- [15m] Activity: Hiding Secrets
- [10m] BREAK
- [25m] Activity: Deployment Definitions
- [15m] Activity: Playlister Reflection
- [20m] Wrap Up: Define a Deployment Plan
- Resources & Credits
By the end of this class, you'll be able to...
- Identify go-to strategies to release web applications.
- Recognize and name the environments used during the development life cycle.
- Protect private keys and other secrets using
dotenv
. - Create and deploy live Flask applications on Heroku.
- On your computer, otherwise known as "locally".
- Where ALL code updates occur.
- Connects to a database on your computer.
- Run your tests here before pushing your code.
- Changes will not affect the live website.
- EXAMPLE:
http://localhost:5000
- All of the code now lives on a server.
- As similar to production as possible.
- EXAMPLE:
https://projectname-test.herokuapp.com
- Highest priority environment.
- Where we "go live", "launch", or "ship" our website.
- Real live people will find bugs you missed while coding!
- EXAMPLE:
https://www.projectname.com
Environments can vary, but should be as similar as possible.
Acceptable differences include:
- Environment variables and other configuration settings.
- Different data in your local database versus production.
- Static assets in staging and production (
.css
,.js
) are typically minified into a single, large file.
When an unhandled exception occurs in your application, your website will go offline. This is known as downtime.
Even minor differences can cause these kinds of unanticipated failures in production --- even if it worked perfectly in development!
Sometimes you can't save everything into your code files because that would be insecure. For example, if you use a third party service like Amazon Web Services (AWS), then there will be sensitive keys that if you expose to the world on a public Github repo, hackers will steal them and use your codes to rack up hundreds of dollars in fees.
To secure such data, developers use environment variables,stored locally and in production.
Why is it important to hide your API key?
- More secure
- Industry-standard practice
Add the python-dotenv
package to your Gif Search project:
$ pip3 install python-dotenv
Add a .env
file with the following key-value pair:
TENOR_API_KEY=yourapikeyvalue
- Keys and their values are separated by
=
- No spaces in the key
- PROTIP: Don't use quotes in this file!
Add the following code at the very top of your app.py
file:
import os
from dotenv import load_dotenv
load_dotenv()
This code imports the python-dotenv
library and loads all the settings in your .env
file!
Grab any setting you defined in the .env
file via os.getenv()
:
import os
from dotenv import load_dotenv
load_dotenv()
TENOR_API_KEY = os.getenv("TENOR_API_KEY")
Add .env
to the bottom of your .gitignore
file.
Heroku is a turn-key server solution that serves as the staging and production servers for many, including Make School!
It combines web hosting functionality with a rich marketplace of plugins to extend and enhance your server --- like an app store for your web application!
Using the Glossary of Heroku Terminology, use your own words to define the following terms:
|
|
Discuss, then spend about 15 minutes writing one short sentence for each term.
Write down any issues you had while deploying Playlister.
- What broke?
- What didn't make sense?
- Did anyone around you face the same issues?
After a few minutes, we'll talk about the challenges you encountered!
- Consider the features you'll be developing for your contractor project.
- Write down three opportunities to push to staging during your development cycle.
- Review these potential deployments with someone you haven't worked with yet!
Contractor Project MVP due on Monday, Dec. 9
Quiz 3 on Thursday, Dec. 5 - Study Guide now available
There will be a Quiz Make-up/Retake session on Friday, Dec. 6 at 12:30PM - Or schedule with me individually.
Go to https://make.sc/bew1.1-vibe-check and fill out the form.