Vercel Python Server not handling a post request

Hey, I’m hosting a python server that has a post request that needs to be sent.

This is how I’m sending the post request:

curl -X POST https://gemini-offline-knowledge.vercel.app/send -H "Content-Type: application/json; " -d '{"text": "The API worked!"}'

This is what I have in my python server:

app = Flask(__name__)

@app.route('/send/', methods=['POST'])
def send_sms():
    pprint(request)
    if request.is_json:
        # send sms with whatever is in body
        print (responseData)
        print("Message sent successfully.")
    return ('', 204)

if __name__ == "__main__":
    app.run(debug=True)

this is what it returned:

<!doctype html>
<html lang=en>
<title>Redirecting...</title>
<h1>Redirecting...</h1>
<p>You should be redirected automatically to the target URL: <a href="https://gemini-offline-knowledge.vercel.app/send/">https://gemini-offline-knowledge.vercel.app/send/</a>. If not, click the link.

My guess is there’s something additional I’d need to add to the headers.

Hi @anshroy2,

You’re listening on the /send/ GET route (see the trailing slash), but you’re only requesting /send (without the trailing slash).

If you either remove the trailing slash from your function or add the slash to your request, you’ll see a successful response:

→ curl -X POST https://gemini-offline-knowledge.vercel.app/send/ -H "Content-Type: application/json; " -d '{"text": "The API worked!"}'
Message sent successfully
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.