def main(): import logging init_log(level=logging.DEBUG) class Temp(HTTPResponse): def get(self): return template("graily_test.html", {'parameters': self.parameters, 'name': 'Graily'}) class Test(HTTPResponse): def get(self, name): return "hello, {}".format(name) def post(self, name): return template("graily_test.html", parameters=self.parameters, name=name) class ConTest(HTTPResponse): @Concurrent.register def get(self): time.sleep(5) # won't block the main Thread return "hello from Graily concurrent" app = Graily([ (r'^/temp/$', Temp), (r'^/static/(.*)$', StaticFileHandler.set_path("static")), (r'^/con/$', ConTest), (r'^/(.*)/$', Test), ]) app.server_bind(("", 8888)) app.serve_forever()
def main(): import logging init_log(level=logging.DEBUG) class Temp(HTTPResponse): def get(self): return template("graily_test.html", { 'parameters': self.parameters, 'name': 'Graily' }) class Test(HTTPResponse): def get(self, name): return "hello, {}".format(name) def post(self, name): return template("graily_test.html", parameters=self.parameters, name=name) class ConTest(HTTPResponse): @Concurrent.register def get(self): time.sleep(5) # won't block the main Thread return "hello from Graily concurrent" app = Graily([ (r'^/temp/$', Temp), (r'^/static/(.*)$', StaticFileHandler.set_path("static")), (r'^/con/$', ConTest), (r'^/(.*)/$', Test), ]) app.server_bind(("", 8888)) app.serve_forever()
def main(): import logging init_log(level=logging.DEBUG) class Echo(StreamRequestHandler): @Concurrent.register def dataReceived(self): time.sleep(5) # won't block the main Thread self.write(self.data) server = ThreadPollTCPServer(("", 8888), Echo) server.serve_forever()
def main(): import logging init_log(level=logging.DEBUG) class Test(BaseHTTPRequestHandler): def GET(self): return "hello from graily httpserver" def POST(self): return str(self.parameters) server = HTTPServer(("", 8888), Test) server.serve_forever()
def main(): import logging init_log(level=logging.DEBUG) class Test(HTTPResponse): def get(self): return "hello from Graily and tornado WSGIServer" app = Graily([(r'^.*$', Test)]) container = wsgi.WSGIContainer(app) http_server = httpserver.HTTPServer(container) http_server.listen(8888) tornado.ioloop.IOLoop.instance().start()
def main(): import logging init_log(level=logging.DEBUG) class Echo(StreamRequestHandler): def verify_request(self): # Request finished when received data ends with '.', # you can also define your own protocol return bytes([self.iostream._read_buffer[-1]]) == b'.' def dataReceived(self): self.write(self.data) server = TCPServer(("", 8888), Echo) server.serve_forever()
def main(): init_log(level=logging.DEBUG) app = default_app() server = make_server(("", 8888), app) server.serve_forever()