Changes between Version 1 and Version 2 of Falcon(webapi)


Ignore:
Timestamp:
Mar 9, 2017, 1:42:14 PM (5 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Falcon(webapi)

    v1 v2  
    6464とこんな感じで、新しいサーバサイドの構成を考えています。
    6565tinydbやmongodbを組み込めば、dbの中身をそのまま返せますね。
     66
     67
     68example.py
     69
     70{{{
     71import json
     72import falcon
     73
     74
     75class HelloResource(object):
     76
     77    def on_get(self, req, resp):
     78        msg = {
     79            "message": "Welcome to the Falcon"
     80        }
     81        resp.body = json.dumps(msg)
     82
     83app = falcon.API()
     84app.add_route("/", HelloResource())
     85
     86
     87if __name__ == "__main__":
     88    from wsgiref import simple_server
     89    httpd = simple_server.make_server("127.0.0.1", 8000, app)
     90    httpd.serve_forever()
     91}}}
    6692
    6793= tinydb =