Search code examples
pythonnginxflaskuwsgiflask-restplus

Flask_restPLUS + NGINX TypeError


I am developing an api using FLASK restPLUS + NGINX and with my intial route getting a type error:

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.

My api.py looks like:

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

My project tree is:

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

Solution

  • The decorator is wrong. I have app.route needs to be api.route