Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Created Jul 10, 2016
Embed
What would you like to do?
【Python】Bottleを使ってJSON形式のレスポンスを返すサンプル
from bottle import route, run, HTTPResponse
import os
@route("/sample.json")
def json():
body = {"status": "OK", "message": "hello world"}
r = HTTPResponse(status=200, body=body)
r.set_header("Content-Type", "application/json")
return r
run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment