adierebel / Flask config example

02 Dec 2017 at 04:21

1 from flask import Flask
2
3 app = Flask(__name__)
4 app.config.from_object('config')
5
6 @app.route("/")
7 def home():
8 # Print available configuration
9 print(app.config)
10
11 # Get value from config
12 Value = app.config.get("KAMPRET_BGT")
13 return Value
14
15 # Run
16 app.run()
1 DEBUG = True
2 SECRET_KEY = 'you-will-never-guess'
3
4 # Custom variable
5 KAMPRET_BGT = 'kampret is bat...'

Run

python3 app.py

Open browser: http://localhost:5000/

Comments (0)