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
String file contents |
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
String file contents |
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
String file contents |
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
String file contents |
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
String file contents |
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 tornado.httpclient | |
import tornado.ioloop | |
import tornado.web | |
import tornado.websocket | |
import tornado.template | |
import tornado.gen | |
import tornado.autoreload | |
import time, json | |
import tornado.httpserver |
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 asyncio | |
@asyncio.coroutine | |
def factorial(name, number): | |
f = 1 | |
for i in range(2, number+1): | |
print("Task %s: Compute factorial(%s)..." % (name, i)) | |
yield from asyncio.sleep(1) | |
f *= i | |
print("Task %s: factorial(%s) = %s" % (name, number, f)) |
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 tornado.web | |
import tornado.gen | |
from tornado.httpclient import AsyncHTTPClient | |
class GenAsyncHandler(tornado.web.RequestHandler): | |
@tornado.gen.coroutine | |
def get(self): | |
http_client = AsyncHTTPClient() | |
response = yield http_client.fetch("http://ip.jsontest.com") | |
print(response) |
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 tornado.ioloop | |
from tornado.httpclient import AsyncHTTPClient | |
def handle_request(response): | |
'''callback needed when a response arrive''' | |
if response.error: | |
print("Error:", response.error) | |
else: | |
print('called') | |
print(response.body) |
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
var express = require('express'); | |
var appln = express(); | |
appln.get('/', function(request, response){ | |
response.set('Content-Type', 'text/plain'); | |
response.send('hello world'); | |
}); | |
appln.listen(3000); | |
appln.set('Hello', 'Express Node'); |