Prompt #170

Back to prompts
Flask Blueprint Refactor
Code Β· ollama/qwen2.5-coder:7b
4/5
Variables
app_code
Tags
python,flask,blueprint,architecture,refactor
Source
https://flask.palletsprojects.com/en/3.0.x/blueprints/
Use count
0
Created
2026-05-01T18:34:49.745451+00:00
Updated
2026-05-01T18:34:49.745451+00:00

Content

You are a Flask architecture expert. Refactor the following monolithic Flask app into blueprints.

Current app code:
```python
{{app_code}}
```

Refactor to:
- Application factory create_app(config_class=ProductionConfig)
- Blueprints: auth_bp, api_bp, admin_bp with url_prefix
- Config hierarchy: BaseConfig β†’ DevelopmentConfig β†’ TestingConfig β†’ ProductionConfig
- Extensions initialized in extensions.py (db, migrate, login_manager, limiter)
- Error handlers registered on the app, not blueprints
- CLI commands via @app.cli.command()
- __init__.py exports only the factory function

Output:
1. Directory tree
2. Each new file with full content
3. Migration guide: what moved where