Frank
Frank

Reputation: 1407

Flask 500/404 errors

I'm experiencing an error with Flask. If I call the @app.route with the function, I retrieve 404 Not Found:

from flask import Flask, request
import requests

app = Flask(__name__) 

@app.route('/webhook', methods=['GET', 'POST'])
def webhook():
    return 'Hello!'

if __name__ == '__main__':
    app.run("0.0.0.0", port=10101, debug=False)

However, if the function is not mentioned, I retrieve the 500 Internal Server Error:

from flask import Flask, request
import requests

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def webhook():
    return 'Hello!'

if __name__ == '__main__':
    app.run("0.0.0.0", port=10101, debug=False)

Any help, please?

Upvotes: 0

Views: 439

Answers (1)

dmitrybelyakov
dmitrybelyakov

Reputation: 3864

Your code runs fine. I just copy-pasted your original example and did a curl request to it with:

curl -X GET http://localhost:10101/webhook
curl -X POST --data "test=true" http://localhost:10101/webhook

Both return Hello!%

As suggested by @Sebastian Speitel - try enabling debug mode - that will give you an idea of what fails and why:

app.run("0.0.0.0", port=10101, debug=True)

Upvotes: 1

Related Questions