Flask
http://docs.jinkan.org/docs/flask/
pip install Flask
最小应用
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run()
web.py
pip install web.py
最小应用
import web urls = ( '/', 'index' ) class index: def GET(self): return "Hello, world!" if __name__ == "__main__": app = web.application(urls, globals()) app.run()
tornado
http://www.tornadoweb.org/en/stable/
pip install tornado
最小应用
from tornado.web import Application from tornado.web import RequestHandler from tornado.ioloop import IOLoop class IndexHandler(RequestHandler): def get(self): self.write("hello world") handlers = [ ("/", IndexHandler), ] if __name__ == '__main__': app = Application(handlers) app.listen(8080) # http://localhost:8080/ IOLoop.current().start()
总结:
三个web框架,基本相似,都是: