This quickstart demonstrates using the Firebase SDK for Cloud Functions with an HTTPS trigger that's triggered through a Firebase Hosting URL. The function will display a repeated number of "BONG" depending on the hour of the day.
The function bigben
returns an HTML page that display a repeated number of "BONG" depending on the hour of the day.
Further reading:
Clone or download this repo and open the quickstarts/big-ben
directory.
Create a Firebase Project on the Firebase Console.
Set up your Firebase project by running firebase use --add
, select your Project ID and follow the instructions.
You need to have installed the Firebase CLI. If you haven't run:
npm install -g firebase-tools
Doesn't work? You may need to change npm permissions.
Start serving your project locally using firebase serve --only hosting,functions
Open the app in a browser at https://localhost:5000/
.
A page containing a repeated number of "BONG" - One for each hour of the day - will be displayed.
You can click on the Refresh button which will call the API by doing an XHR to /api
and refresh the "BONG" display on the page.
First you need to install the npm
dependencies of the functions:
cd functions && npm install; cd ..
This installs locally the Firebase SDK and the Firebase Functions SDK.
Deploy to Firebase using the following command:
firebase deploy
This deploys and activates the bigben
Function.
The first time you call
firebase deploy
on a new project with Functions will take longer than usual.
After deploying the function you can open the following URL in your browser:
https://<your-project-id>.firebaseapp.com/bigben
A page containing a repeated number of "BONG" will be displayed.
We'd love that you contribute to the project. Before doing so please read our Contributor guide.
© Google, 2016. Licensed under an Apache-2 license.