Skip to content

Instantly share code, notes, and snippets.

View YoonHan's full-sized avatar
🐢
Improve steadily

Yoon Han YoonHan

🐢
Improve steadily
View GitHub Profile
@YoonHan
YoonHan / decorators.py
Last active September 2, 2021 08:21
decorator function example: json data utf8 encoding & wrap it with Flask Response
from flask import Response
from functools import wraps
import json
# Define decorator factory
# with argument 'status_code' which means status code of http response
def utf8_encoding(status_code=200):
def decorator(f):
@wraps(f)
def decorated_function(*args, **kwargs):