Skip to content

pratikkalein/cloud-function-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code Generator

Demo of how to setup and deploy Google Cloud function using Python
View Demo »

About The Project

This project demonstrates how to deploy a cloud function on Google Cloud.

Built With

Python Flask Flask Flask

Getting Started

Setting up your Google Cloud account

  1. Open the Google Cloud website and create an account.
  2. Create a billing account and activate billing.
  3. Create a new project.

Create a new cloud function

  1. Open Cloud Functions from the hamburger menu or using the search.
  2. Click on CREATE FUNCTION.
    new-btn
  3. Add a function name and choose a region.
  4. Click on Allow unauthenticated invocations.
    config-1
  5. Open Runtime, build, connections and security settings by clicking on the down arrow.
  6. Under autoscaling change the Minimum number of Instances to 0 and Maximum number of Instances to 2. config-1
  7. Click on NEXT.

Code

  1. Choose the runtime as Python 3.9.
  2. Copy the code from cloud-function.py and paste it into the main.py file.
  3. Copy the requirements from requirements.txt and paste it into the requirements.txt file.
  4. Click on DEPLOY. code
  5. It usually takes 1-2 minutes deploy the function. Once deployed you will get a URL to trigger the function.
  6. You can test the function using this URL by adding ?link=https://yourlink.com
https://us-central1-project-name.cloudfunctions.net/function-2?link=https://yourlink.com
  1. You can integrate the link in your app. Check the main.py for an example.

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Pratik Kale

Project Link: https://github.com/pratikkalein/cloud-function-demo
Demo Link : http://pratik.tech/gcf-demo