Using Gevent in flask: API is not asynchronous

后端 未结 3 2078
死守一世寂寞
死守一世寂寞 2021-01-15 23:16

Earlier I was using Waitress. Now I\'m using Gevent to run my Flask app that has only one API

from flask import Flask, request, jsonify
import documentUtil
fr         


        
3条回答
  •  长发绾君心
    2021-01-15 23:42

    """index.py"""
    
    from flask import Flask
    from flask import jsonify
    
    app = Flask(__name__)
    
    
    @app.route('/')
    def index():
        """Main page"""
        doc = {
            'site': 'stackoverflow',
            'page_id': 6347182,
            'title': 'Using Gevent in flask'
        }
        return jsonify(doc)
    
    
    # To start application
    gunicorn -k gevent --bind 0.0.0.0 index:app
    
    k : worker_class
    --bind : bind address
    # See https://docs.gunicorn.org/en/latest/settings.html
    

提交回复
热议问题