Python WEB flask from flask import Flask app

  • Slides: 10
Download presentation
Python WEB框架

Python WEB框架

简单的flask应用 from flask import Flask app = Flask(__name__) @app. route('/') def hello_world(): return 'Hello

简单的flask应用 from flask import Flask app = Flask(__name__) @app. route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app. run()

Tornado简单使用 import tornado. ioloop import tornado. web class Main. Handler(tornado. web. Request. Handler): def

Tornado简单使用 import tornado. ioloop import tornado. web class Main. Handler(tornado. web. Request. Handler): def get(self): self. write("Hello, world") application = tornado. web. Application([ (r"/index", Main. Handler), ]) if __name__ == "__main__": application. listen(8888) tornado. ioloop. IOLoop. instance(). start()

Sanic简单应用 from sanic import Sanic from sanic. response import json app = Sanic() @app.

Sanic简单应用 from sanic import Sanic from sanic. response import json app = Sanic() @app. route("/") async def test(request): return json({"hello": "world"}) if __name__ == "__main__": app. run(host="127. 0. 0. 1", port=8080)