Best practices for Flask web development including routing, blueprints, and testing.
Best practices for Flask web development including routing, blueprints, and testing.
Apply this skill when building Flask web applications or APIs — routing, blueprints, extensions, and testing.
create_app()) to avoid global state and enable testing.config.py with classes like DevelopmentConfig, ProductionConfig.@app.get, @app.post) over generic @app.route with methods=[...].flask.abort() with appropriate HTTP codes rather than returning error responses manually.ext.init_app(app) inside the factory, not at module level.app.test_client() for HTTP-level tests and app.test_request_context() for unit tests.session for the app, function for the client).TESTING=True and use a separate test database.app.run()) in production — use Gunicorn or uWSGI.app object; use g for request-scoped data.SECRET_KEY — load from environment variables.