Created
February 10, 2014 07:18
-
-
Save yuuichi-fujioka/8911702 to your computer and use it in GitHub Desktop.
REST API with pecan
This file contains hidden or 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
import eventlet | |
from eventlet import wsgi | |
import pecan | |
from pecan import rest | |
class V1Controller(rest.RestController): | |
@pecan.expose() | |
def get(self, id): | |
return id | |
class Root(object): | |
v1 = V1Controller() | |
config = { | |
'root': Root, | |
'debug': True, | |
} | |
def _make_app(): | |
app = pecan.make_app(**config) | |
return app | |
def main(): | |
eventlet.monkey_patch() | |
app = _make_app() | |
wsgi.server(eventlet.listen(('', 8899)), app) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment