Tornado est un framework Web / bibliothèque réseau en Python.
$ pip install tornado --user
Collecting tornado
Collecting singledispatch (from tornado)
Using cached singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting certifi (from tornado)
Using cached certifi-2016.9.26-py2.py3-none-any.whl
Collecting backports-abc>=0.4 (from tornado)
Using cached backports_abc-0.5-py2.py3-none-any.whl
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado)
Installing collected packages: singledispatch, certifi, backports-abc, tornado
Successfully installed backports-abc-0.5 certifi-2016.9.26 singledispatch-3.4.0.3 tornado-4.4.2
Un serveur Web qui renvoie "Hello World" avec un accès GET à /.
server.py
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello World\n");
def make_app():
return tornado.web.Application([
(r"/", MainHandler)
])
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
$ python server.py
$ wget -q -O - http://localhost:8888/
Hello World
--D'accord
Recommended Posts