Created
July 10, 2016 02:12
-
-
Save kurozumi/2cb1a8c1bca2e58662da367ffbc31b24 to your computer and use it in GitHub Desktop.
【Python】Bottleを使ってJSON形式のレスポンスを返すサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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