1

I'm trying to deploy my flask api rest on nginx (on a subdomain) without success. I've followed this example from Digital Ocean and everything was working properly but then I changed the tutorial example code to my mine and POST requests aren't working at all. I'm using Postman Chrome App and each time I do a POST request to "api.domain.com/CreateUser" I get a 404 error:

"The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."

This is my VH config:

server {
    listen 80;
    server_name api.domain.com;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/ubuntu/apirest/apirest.sock;
    }
}

And this is the python file (flask api sample):

from flask import Flask, jsonify, url_for, redirect, request
from flask_restful import Resource, Api, reqparse
from flask_cors import CORS, cross_origin

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

class CreateUser(Resource):
    def post(self):
        return jsonify({
            'status': 'ok', 
            'message': 'user successfuly created'
        })

api.add_resource(CreateUser, '/CreateUser')

if __name__ == '__main__':
    app.run(host='0.0.0.0')

Anyone has a clue about what's happening? Thanks so much!

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.