Skip to content

Instantly share code, notes, and snippets.

@andrewsmedina
Forked from rochacbruno/nacho_test.py
Created August 19, 2013 05:17
Show Gist options
  • Save andrewsmedina/6265929 to your computer and use it in GitHub Desktop.
Save andrewsmedina/6265929 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from nacho.services.servers import NachoServer
from nacho.services.routers import Routers
from nacho.controllers.base import ApplicationController
from tornado.escape import json_encode
class MainHandler(ApplicationController):
def get(self):
data = {'name': 'A Royal Baby', 'body':'A slow news week'}
self.finish(json_encode(data))
r = Routers(
[
(r"/", MainHandler),
],
template_path=os.path.join(os.path.dirname(__file__), "views"),
)
if __name__ == "__main__":
r.listen(8888)
server = NachoServer()
server.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment