Python/http-flask/README.md
This sample demonstrates how to expose a Flask app as a single Cloud Function. The Flask app provides a simple CRUD interface for "widgets" stored in the Realtime Database.
See file functions/main.py for the code.
The sample creates a Flask app and defines two routes:
GET /widgets and GET /widgets/<id>: These routes retrieve a list of all widgets or a single widget by its ID from the Realtime Database.POST /widgets: This route adds a new widget to the Realtime Database.The entire Flask app is then exposed as a single Cloud Function called httpsflaskexample using @https_fn.on_request().
The httpsflaskexample function is triggered by an HTTP request.
To deploy and test the sample:
git clone https://github.com/firebase/functions-samplescd functions-samples/Python/http-flaskfirebase use --add and select your Firebase project.firebase deploy.curl to test the function:
curl -X POST -d "My new widget" https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgetscurl https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgetscurl https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgets/WIDGET_ID