fix cors
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import functions_framework
|
import functions_framework
|
||||||
from google.cloud.firestore_v1.base_query import FieldFilter
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||||
import firebase_admin
|
from firebase_admin import initialize_app, credentials, firestore
|
||||||
from firebase_admin import credentials, firestore
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
initialize_app()
|
||||||
|
|
||||||
@functions_framework.http
|
@functions_framework.http
|
||||||
def clear_users(request):
|
def clear_users(request):
|
||||||
"""HTTP Cloud Function.
|
"""HTTP Cloud Function.
|
||||||
@@ -29,9 +30,6 @@ def clear_users(request):
|
|||||||
'Access-Control-Allow-Origin': '*'
|
'Access-Control-Allow-Origin': '*'
|
||||||
}
|
}
|
||||||
|
|
||||||
key_path = os.getcwd() + '/hpos-preprod-firebase-adminsdk-d6jjt-ae42ad0f67.json'
|
|
||||||
cred = credentials.Certificate(key_path)
|
|
||||||
firebase_admin.initialize_app(cred)
|
|
||||||
db = firestore.client()
|
db = firestore.client()
|
||||||
source_collection = "patientData"
|
source_collection = "patientData"
|
||||||
|
|
||||||
@@ -47,13 +45,10 @@ def clear_users(request):
|
|||||||
doc_data = doc.to_dict()
|
doc_data = doc.to_dict()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Delete the document from the source collection
|
|
||||||
db.collection(source_collection).document(doc_id).update({"testStatus": True})
|
db.collection(source_collection).document(doc_id).update({"testStatus": True})
|
||||||
print(f"Document with ID '{doc_id}' updated")
|
print(f"Document with ID '{doc_id}' updated")
|
||||||
count = count + 1
|
count = count + 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error deleting document with ID '{doc_id}' from the source collection: {e}")
|
print(f"Error deleting document with ID '{doc_id}' from the source collection: {e}")
|
||||||
|
|
||||||
firebase_admin.delete_app(firebase_admin.get_app())
|
return ('cleared users: {}!'.format(count), 200, headers)
|
||||||
|
|
||||||
return 'cleared users: {}!'.format(count)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user