Flask_restPLUS + NGINX TypeError

问题描述 投票:0回答:1

我正在使用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
python nginx flask uwsgi flask-restplus
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.