forked from ozgur/python-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase_example.py
More file actions
27 lines (19 loc) · 845 Bytes
/
Copy pathfirebase_example.py
File metadata and controls
27 lines (19 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import datetime
from firebase.firebase import FirebaseApplication, FirebaseAuthentication
if __name__ == '__main__':
SECRET = '12345678901234567890'
DSN = 'https://firebase.localhost'
EMAIL = 'your@email.com'
authentication = FirebaseAuthentication(SECRET,EMAIL, True, True)
firebase = FirebaseApplication(DSN, authentication)
firebase.get('/users', None,
params={'print': 'pretty'},
headers={'X_FANCY_HEADER': 'very fancy'})
data = {'name': 'Ozgur Vatansever', 'age': 26,
'created_at': datetime.datetime.now()}
snapshot = firebase.post('/users', data)
print(snapshot['name'])
def callback_get(response):
with open('/dev/null', 'w') as f:
f.write(response)
firebase.get_async('/users', snapshot['name'], callback=callback_get)