KayChen

记录技术生活的点点滴滴

0%

Flask+Gevent实现异步非阻塞访问

1
2
3
4
5
6
7
8
9
10
11
12
13
from flask import Flask
from gevent import monkey
from gevent.pywsgi import WSGIServer
monkey.patch_all()
app = Flask(__name__)

@app.route("/")
def hello():
return "Welcome to Flask!"

if __name__ == "__main__":
http_server = WSGIServer(('0.0.0.0', 5000), app)
http_server.serve_forever()