這裡我們從本地類當中取值:
from flask import Flask
class DefaultConfig(object):
"""default project config"""
USER = "zhang"
PWD ="<PASSWORD>"
app=Flask(__name__)
app.config.from_object(DefaultConfig)
@app.route('/')
def index():
print(app.config['USER'])
print(app.config['PWD'])
return "Hello World!"
if __name__ == '__main__':
app.run()