Skip to content

Commit 4251c6a

Browse files
authored
Merge pull request #181 from realpython/python-flask-example-heroku
python-flask-example-heroku materials
2 parents ceb25cd + c13cb70 commit 4251c6a

File tree

6 files changed

+43
-0
lines changed

6 files changed

+43
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
venv
2+
__pycache__
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn app:app
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Source files supporting the [Deploying a Python Flask Example Application Using Heroku](https://realpython.com/python-flask-example-heroku/) article on [Real Python](https://realpython.com/).

python-flask-example-heroku/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
from flask import Flask
3+
4+
app = Flask(__name__)
5+
env_config = os.getenv("APP_SETTINGS", "config.DevelopmentConfig")
6+
app.config.from_object(env_config)
7+
8+
9+
@app.route("/")
10+
def index():
11+
secret_key = app.config.get("SECRET_KEY")
12+
return f"The configured secret key is {secret_key}."
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
3+
4+
class Config:
5+
DEBUG = False
6+
DEVELOPMENT = False
7+
SECRET_KEY = os.getenv("SECRET_KEY", "this-is-the-default-key")
8+
9+
10+
class ProductionConfig(Config):
11+
pass
12+
13+
14+
class StagingConfig(Config):
15+
DEBUG = True
16+
17+
18+
class DevelopmentConfig(Config):
19+
DEBUG = True
20+
DEVELOPMENT = True
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
click==7.1.2
2+
Flask==1.1.2
3+
gunicorn==20.0.4
4+
itsdangerous==1.1.0
5+
Jinja2==2.11.2
6+
MarkupSafe==1.1.1
7+
Werkzeug==1.0.1

0 commit comments

Comments
 (0)