cloud-run-gemini-chat/Application/CloudRun/Python-Django/geminiapp/gcp_utils.py [1:34]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''
This module implements various Google Cloud Project functions
'''

import requests

def get_project_id():
	'''
	This function reads the Google Cloud Project ID from the Metadata service
	'''

	try:
		url = "http://metadata.google.internal/computeMetadata/v1/project/project-id"
		# url = "http://metadata.goog/v1/project/project-id"

		headers = {
			"Metadata-Flavor": "Google"
		}

		response = requests.get(url, headers=headers, timeout=0.5)

		if response.status_code >= 400:
			print(response.content)		# print error message
			return None

		return response.content.decode("utf-8")
	except Exception as e:
		print(e)		# print error message
		return None

def get_client_ip():
	'''
	Returns the client IP address.
	That IP might be IPv4 or IPv6 depending on how the client connected.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



cloud-run-gemini-chat/Application/CloudRun/Python-Flask/gcp_utils.py [1:36]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''
This module implements various Google Cloud Project functions
'''
# Flask imports
from flask import request

import requests

def get_project_id():
	'''
	This function reads the Google Cloud Project ID from the Metadata service
	'''

	try:
		url = "http://metadata.google.internal/computeMetadata/v1/project/project-id"
		# url = "http://metadata.goog/v1/project/project-id"

		headers = {
			"Metadata-Flavor": "Google"
		}

		response = requests.get(url, headers=headers, timeout=0.5)

		if response.status_code >= 400:
			print(response.content)		# print error message
			return None

		return response.content.decode("utf-8")
	except Exception as e:
		print(e)		# print error message
		return None

def get_client_ip():
	'''
	Returns the client IP address.
	That IP might be IPv4 or IPv6 depending on how the client connected.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



