2

How can I tell my function to respond to an endpoint specified on the received message with a HTTP Post response in Google Cloud function? In the code, or the trigger configuration, or in the package json?

I think I'm looking for something like this but in python:

2 Answers 2

2

All you need is just this - return Response('No file uploaded', status=500) Check this out - https://www.programcreek.com/python/example/51515/flask.Response

FYI, A Google Cloud Function uses a Flask Response object - http://flask.pocoo.org/docs/0.12/api/#flask.Flask.make_response

Sign up to request clarification or add additional context in comments.

Comments

0

This is the link to google's answer: https://cloud.google.com/functions/docs/writing/http I used this link to write this solution:

    headers= {
        'Access-Control-Allow-Origin': '*',
        'Content-Type':'application/json'
        }


    id1= "1234567"
    var1= "variable 1"

    text = '{"id1":"'+id1+'","var1":"'+var1+'"}'
    print(text)
    return (text, 200, headers)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.