feat: Refactor app initialization for clarity

Refactored app initialization in `main.py` by encapsulating the Flask server start-up configuration into a `main` function. This change improves code readability and organization, making the execution flow clearer, especially when the application starts or is debugged. Previously, the server start-up logic was directly in the global scope guarded by `if __name__ == "__main__":`, making the logic slightly less organized. Moving this into a dedicated function allows for potential expansion and easier testing. Additionally, ensured data initialization occurs after server start-up to align with best practices for initial data loading.
This commit is contained in:
Kumi 2024-05-25 17:00:44 +02:00
parent bcc31368f9
commit 6c22ddac8e
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -13,8 +13,11 @@ app.typesense_api_key = get_typesense_api_key()
init_routes(app)
if __name__ == "__main__":
def main():
app.run(port=app.config['PORT'], host=app.config['LISTEN_HOST'], debug=app.config['DEBUG'])
if __name__ == "__main__":
main()
# Initialize data when the server starts
update_data(app)