Snippet library

Copy-ready, tested snippets for Python, Flask, JavaScript, SQL, HTML, CSS and Bash. Open any of them in the playground.

3 snippets

python

Generate a secure random token

Use the secrets module (never random) for passwords, tokens and reset links.

beginner #security#secrets#auth
flask

Login-required decorator for JSON routes

Answer 401 JSON instead of redirecting to the login page.

intermediate #auth#decorators#api
flask

Signed, expiring links

Make email-verification or reset links that expire, without a database table.

intermediate #auth#email#tokens