Install
openclaw skills install flaskAvoid common Flask mistakes — context errors, circular imports, session configuration, and production gotchas.
openclaw skills install flaskcurrent_app only works inside request or with app.app_context() — "working outside application context" errorg is per-request storage — lost after request ends, use for db connectionswith app.app_context(): or pass data, not proxiescreate_app() factory pattern avoids circular imports — import current_app not apprequest, session only inside request — "working outside request context" errorurl_for needs context — url_for('static', filename='x', _external=True) for absolute URLsfrom app import app in models causes circular — use factory patterncurrent_appinit_app(app) pattern — create without app, bind laterSECRET_KEY required for sessions — random bytes, not weak stringSESSION_COOKIE_SECURE=True in production — only send over HTTPSSESSION_COOKIE_HTTPONLY=True — JavaScript can't accessdebug=True in production = remote code execution — attacker can run PythonFLASK_DEBUG env var — not hardcodedurl_prefix set at registration — app.register_blueprint(bp, url_prefix='/api')@bp.route('/users') becomes /api/usersblueprint.before_request only for that blueprint — app.before_request for alldb.session.commit() explicitly — autocommit not defaultdb.session.rollback() on error — or session stays in bad stateflask run is dev server — use Gunicorn/uWSGI in productionthreaded=True for dev server concurrency — but still not production-readyPROPAGATE_EXCEPTIONS=True for proper error handling with Sentry etc.return redirect('/login') vs return redirect(url_for('login')) — url_for is refactor-safereturn jsonify(data) — not return json.dumps(data)request.form — JSON body in request.json or request.get_json()request.args for query params — request.args.get('page', default=1, type=int)