Update app.py
Browse files
app.py
CHANGED
|
@@ -27,11 +27,17 @@ app.include_router(router)
|
|
| 27 |
# Initialize Firebase Admin SDK
|
| 28 |
try:
|
| 29 |
cred = credentials.Certificate("serviceAccountKey.json")
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
db = firestore.client()
|
| 32 |
except Exception as e:
|
| 33 |
logger.error(f"Failed to initialize Firebase Admin SDK: {str(e)}")
|
| 34 |
raise
|
|
|
|
| 35 |
class UpdateStatusRequest(BaseModel):
|
| 36 |
userId: str
|
| 37 |
medicineName: str
|
|
|
|
| 27 |
# Initialize Firebase Admin SDK
|
| 28 |
try:
|
| 29 |
cred = credentials.Certificate("serviceAccountKey.json")
|
| 30 |
+
try:
|
| 31 |
+
# if an app is already initialized, this will succeed
|
| 32 |
+
firebase_admin.get_app()
|
| 33 |
+
except ValueError:
|
| 34 |
+
# otherwise initialize it exactly once
|
| 35 |
+
firebase_admin.initialize_app(cred)
|
| 36 |
db = firestore.client()
|
| 37 |
except Exception as e:
|
| 38 |
logger.error(f"Failed to initialize Firebase Admin SDK: {str(e)}")
|
| 39 |
raise
|
| 40 |
+
|
| 41 |
class UpdateStatusRequest(BaseModel):
|
| 42 |
userId: str
|
| 43 |
medicineName: str
|