小编Wuk*_*uke的帖子

使用 Flask、Nginx 和 uwsgi 获得 404

我有一个带有 virtualenv的Flask应用程序/find_bili_user/app.py/python_envs/env1/

app.py

from flask import Flask, jsonify, request, make_response

from biliuser import getdanmu

app = Flask('__name__')


@app.route('/find_bili_user.json', methods=['GET'])
def get_user():
    avid = request.args.get('avid')
    if not avid or not avid.isdigit():
        return invalid_avid()
    else:
        message = getdanmu(int(avid))
        if not message:
            return failed()
        else:
            response = jsonify(message)
            return response


@app.errorhandler(400)
def invalid_avid():
    return make_response(jsonify({'error': 'invalid avid.'}), 400)


@app.errorhandler(400)
def failed():
    return make_response(jsonify({'error': 'failed parsing comments.'}), 400)


if __name__ == '__main__':
    app.run()
Run Code Online (Sandbox Code Playgroud)

我的 uwsgi 配置:

[uwsgi]
chdir …
Run Code Online (Sandbox Code Playgroud)

python nginx uwsgi

1
推荐指数
1
解决办法
2642
查看次数

标签 统计

nginx ×1

python ×1

uwsgi ×1