我正在使用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
答案 0 :(得分:0)
装饰器错误。我有app.route
必须是api.route