Skip to content

Commit 39a0537

Browse files
committed
python-flask-example-heroku materials
1 parent c1bc7de commit 39a0537

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
venv
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
from flask import Flask
3+
4+
app = Flask(__name__)
5+
app.config.from_object(os.getenv("APP_SETTINGS", "config.DevelopmentConfig"))
6+
7+
8+
@app.route("/")
9+
def index():
10+
return f"The configured secret key is {app.config.get('SECRET_KEY')}"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
3+
4+
class Config(object):
5+
DEBUG = False
6+
TESTING = False
7+
SECRET_KEY = os.getenv("SECRET_KEY", "this-is-read-from-env")
8+
9+
10+
class ProductionConfig(Config):
11+
DEBUG = False
12+
13+
14+
class StagingConfig(Config):
15+
DEVELOPMENT = True
16+
DEBUG = True
17+
18+
19+
class DevelopmentConfig(Config):
20+
DEVELOPMENT = True
21+
DEBUG = 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)