{
"text": "mike made the coolest API",
"search": "sarcastic wonka"
}
@app.route('/', methods = ['GET', 'POST'])
def giffer():
if request.method == 'POST':
data = request.data
gif_file = gif_factory.create(**data)
return send_file(gif_file)
else:
return get_guide_text()
@app.route('/', methods = ['POST'])
async def giffer(request):
data = request.json
gif_file = await gif_factory.create(**data)
return file(gif_file, mime_type='image/gif')
Python 3 required
Type Annotations
Autogenerated documentation
"make developing an API as simple as possible"
@hug.post('/', output=hug.output_format.gif_image)
def giffer_post(search: input_search, text: input_text,
text_width: int=60):
return gif_factory.create(search=search, text=text,
text_width=text_width)
By Tom Christie
def show_request(request: http.Request):
return {
'method': request.method,
'url': request.url,
'headers': dict(request.headers)
}
def show_query_params(query_params: http.QueryParams):
return {
'params': dict(query_params)
}
def show_user_agent(user_agent: http.Header):
return {
'user-agent': user_agent
}
Other "kitchen sink" features