@@ -84,18 +84,8 @@ feature_config = posthog.get_feature_flag_payload('new-dashboard-feature', curre
8484
8585The example demonstrates two approaches to error tracking:
8686
87- ** 1. Automatic capture for all 500 errors** (` app/__init__.py ` ):
88- ``` python
89- @app.errorhandler (500 )
90- def internal_server_error (e ):
91- # Capture 500 errors in PostHog - remove this if you want manual control
92- posthog.capture_exception(e)
93- if request.path.startswith(' /api/' ):
94- return jsonify({" error" : " Internal server error" }), 500
95- return render_template(' errors/500.html' ), 500
96- ```
87+ Manual capture for specific critical operations** (` app/api/routes.py ` ).
9788
98- ** 2. Manual capture for specific critical operations** (` app/api/routes.py ` ):
9989``` python
10090try :
10191 # Critical operation that might fail
@@ -137,18 +127,3 @@ basics/flask/
137127├── README.md
138128└── run.py # Entry point
139129```
140-
141- ## Key Differences from Django Version
142-
143- | Aspect | Django | Flask |
144- | --------| --------| -------|
145- | Project Structure | Single app in project | Application factory + blueprints |
146- | Database | SQLite via Django ORM | SQLite via Flask-SQLAlchemy |
147- | User Model | Built-in ` auth.User ` model | Custom SQLAlchemy ` User ` model |
148- | User Registration | Django admin / ` createsuperuser ` | ` /signup ` route with form |
149- | Authentication | Django auth system | Flask-Login |
150- | Session Management | Django sessions | Flask sessions (cookie-based) |
151- | Configuration | settings.py | Config classes with app factory |
152- | URL Routing | urls.py patterns | Blueprint route decorators |
153- | PostHog Init | AppConfig.ready() | Application factory |
154- | Error Capture | PostHog middleware auto-captures | Manual with ` @app.errorhandler(500) ` or try/except |
0 commit comments