Flask_restPLUS + NGINX TypeError

时间:2019-11-19 00:54:54

标签: python nginx flask uwsgi flask-restplus

我正在使用FLASK restPLUS + NGINX开发一个api,并且我的初始路由遇到类型错误:

The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a Employee.

我的api.py看起来像:

from flask import Flask
from flask_restplus import Api, Resource

app = Flask(__name__)
api = Api(app)

@app.route("/employee")
class Employee(Resource):
    def get(self):
        response = dict({'hey': 'there'})
        return response

我的项目树是:

app
├── docker-compose.yml
├── flask
│   ├── Dockerfile
│   ├── .dockerignore
│   ├── app
│   │   ├── __init__.py
│   │   └── api.py
│   ├── app.ini
│   ├── requirements.txt
│   └── run.py
├── nginx
│   ├── Dockerfile
│   └── nginx.conf
├── .gitignore
└── readme.md

1 个答案:

答案 0 :(得分:0)

装饰器错误。我有app.route必须是api.route