Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Flask configuration framework to load settings #109

Closed
Tracked by #608
thekaveman opened this issue Aug 3, 2022 · 2 comments · Fixed by #119
Closed
Tracked by #608

Use Flask configuration framework to load settings #109

thekaveman opened this issue Aug 3, 2022 · 2 comments · Fixed by #119
Assignees

Comments

@thekaveman
Copy link
Member

thekaveman commented Aug 3, 2022

Instead of getting config manually from the settings module like:

app = Flask(__name__)
app.name = settings.APP_NAME
app.config["SQLALCHEMY_DATABASE_URI"] = settings.SQLALCHEMY_DATABASE_URI
# etc.

Flask has built-in support for loading the configuration from a number of sources. We're using the Python files format, which would look something like:

app = Flask(__name__)
app.config.from_object("eligibility_server.settings")

We can also load from a number of supported file types:

import json
app.config.from_file("config.json", load=json.load)

Or directly from certain environment variables:

app.config.from_prefixed_env()

Let's use the built-in framework for loading configuration data.

See also: Flask Configuration Best Practices

@thekaveman thekaveman added this to the Courtesy Cards milestone Aug 3, 2022
@thekaveman thekaveman moved this to This Sprint (Month) in Digital Services Aug 3, 2022
@machikoyasuda
Copy link
Member

@machikoyasuda
Copy link
Member

@angela-tran angela-tran self-assigned this Aug 5, 2022
@angela-tran angela-tran moved this from This Sprint (Month) to In Progress in Digital Services Aug 5, 2022
Repository owner moved this from In Progress to Done in Digital Services Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants