Skip to content

Instantly share code, notes, and snippets.


Sh1Yo/ Secret

Last active July 24, 2022 12:59
What would you like to do?
example jwt python3 web app
# the packages flask and pyjwt are required for this application.
from flask import request, abort, Flask
import jwt
app = Flask(__name__)
secret = "secret_key"
def root():
if "Authorization" in request.headers:
data = jwt.decode(request.headers["Authorization"], secret, algorithms="HS256")
return "Your role is %s" % data["role"]
return "Your jwt token is %s" % jwt.encode({"role": "user"}, secret, algorithm="HS256")'', port=2222)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment