Generate a clean code screenshot of a Python Flask API endpoint with syntax highlighting and the Dracula theme. Ready to share on social media or in docs.
Loading editor...
1from flask import Flask, jsonify, request2from functools import wraps3import time4 5app = Flask(__name__)6 7def rate_limit(max_calls, window):8 """Simple rate limiter using a sliding window."""9 calls = []10 def decorator(f):11 @wraps(f)12 def wrapper(*args, **kwargs):13 now = time.time()14 calls[:] = [t for t in calls if now - t < window]15 if len(calls) >= max_calls:16 return jsonify({"error": "Rate limit exceeded"}), 42917 calls.append(now)18 return f(*args, **kwargs)19 return wrapper20 return decorator21 22@app.route("/api/users", methods=["GET"])23@rate_limit(max_calls=100, window=60)24def get_users():25 page = request.args.get("page", 1, type=int)26 per_page = request.args.get("per_page", 20, type=int)27 28 users = User.query.paginate(29 page=page, per_page=min(per_page, 100)30 )31 32 return jsonify({33 "users": [u.to_dict() for u in users],34 "total": users.total,35 "page": page36 })This example renders a Flask API endpoint with a rate limiter as a code screenshot. The Dracula theme provides high contrast for Python syntax, making keywords, strings, and decorators easy to read in the exported image.
The code demonstrates a common backend pattern: pagination, rate limiting, and JSON responses. Sharing this as a screenshot ensures the indentation and formatting stay intact across platforms.
Use the Download PNG button instead of taking a system screenshot. The export renders at 2x pixel ratio, producing crisp text at any display density. System screenshots often capture at 1x resolution, which looks blurry on Retina displays.
Yes. Type your username or handle in the Watermark input field at the bottom. It appears in the bottom-right corner of the exported image, useful for branding when sharing code on social media.
Nothing you paste leaves this tab. Every tool runs entirely in your browser — no upload, no server, no account.