Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -25,7 +25,51 @@ firebase_admin.initialize_app(cred, {
|
|
| 25 |
|
| 26 |
bucket = storage.bucket()
|
| 27 |
api_key = os.environ['Gemini']
|
| 28 |
-
FIREBASE_API_KEY = os.environ.get('FIREBASE_API_KEY')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Helper functions
|
| 31 |
def configure_gemini():
|
|
|
|
| 25 |
|
| 26 |
bucket = storage.bucket()
|
| 27 |
api_key = os.environ['Gemini']
|
| 28 |
+
FIREBASE_API_KEY = os.environ.get('FIREBASE_API_KEY')
|
| 29 |
+
|
| 30 |
+
# Add test account creation function
|
| 31 |
+
def create_test_accounts():
|
| 32 |
+
try:
|
| 33 |
+
# Create/admin2@test.com (Admin)
|
| 34 |
+
try:
|
| 35 |
+
admin_user = auth.create_user(
|
| 36 |
+
email='admin2@test.com',
|
| 37 |
+
password='password1'
|
| 38 |
+
)
|
| 39 |
+
except auth.EmailAlreadyExistsError:
|
| 40 |
+
admin_user = auth.get_user_by_email('admin2@test.com')
|
| 41 |
+
|
| 42 |
+
db.reference(f'users/{admin_user.uid}').set({
|
| 43 |
+
'daily_cash': 300,
|
| 44 |
+
'remaining_cash': 300,
|
| 45 |
+
'last_reset': '2000-01-01T00:00:00+00:00',
|
| 46 |
+
'is_admin': True
|
| 47 |
+
})
|
| 48 |
+
|
| 49 |
+
# Create user1@test.com (Regular user)
|
| 50 |
+
try:
|
| 51 |
+
regular_user = auth.create_user(
|
| 52 |
+
email='user1@test.com',
|
| 53 |
+
password='123456'
|
| 54 |
+
)
|
| 55 |
+
except auth.EmailAlreadyExistsError:
|
| 56 |
+
regular_user = auth.get_user_by_email('user1@test.com')
|
| 57 |
+
|
| 58 |
+
db.reference(f'users/{regular_user.uid}').set({
|
| 59 |
+
'daily_cash': 300,
|
| 60 |
+
'remaining_cash': 300,
|
| 61 |
+
'last_reset': '2000-01-01T00:00:00+00:00',
|
| 62 |
+
'is_admin': False
|
| 63 |
+
})
|
| 64 |
+
|
| 65 |
+
print("Test accounts created/updated successfully")
|
| 66 |
+
except Exception as e:
|
| 67 |
+
print(f"Error creating test accounts: {str(e)}")
|
| 68 |
+
|
| 69 |
+
# Create test accounts when server starts
|
| 70 |
+
create_test_accounts()
|
| 71 |
+
|
| 72 |
+
|
| 73 |
|
| 74 |
# Helper functions
|
| 75 |
def configure_gemini():
|