Skip to content

Commit

Permalink
fix:firebase_init reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-Roshan-lab committed Jan 19, 2024
1 parent c50c194 commit 27ff262
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions python/subscribe_to_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
from firebase_admin import credentials, messaging
import os

# retreive key from env
key = eval(os.environ['KEY'])

# check if app is alr initialized
try:
app = firebase_admin.get_app()
except ValueError as e:
cred = credentials.Certificate(key)
firebase_admin.initialize_app(cred)

def main(context):
key = eval(os.environ['KEY'])
if 'timetable_app' not in firebase_admin._apps:
cred = credentials.Certificate(key)
firebase_admin.initialize_app(cred, name='timetable_app')
context.log(key)
if (context.req.path == "/"):
return context.res.json({"msg": "working, use /subscribe to register users"})
if (context.req.path == "/subscribe"):
Expand Down

0 comments on commit 27ff262

Please sign in to comment.