Spaces:
Sleeping
Sleeping
Download app.py from Huzaifa1435/Carpool_final: direct link, hf CLI and curl.
- Browser
- Download file 837 Bytes
-
https://huggingface.co/spaces/Huzaifa1435/Carpool_final/resolve/main/app.py
- Command line
-
hf download hf://spaces/Huzaifa1435/Carpool_final/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Huzaifa1435/Carpool_final/resolve/main/app.py
837 Bytes
| import os | |
| import firebase_admin | |
| from firebase_admin import credentials, firestore | |
| from flask import Flask, jsonify | |
| app = Flask(__name__) | |
| cred = credentials.Certificate({ | |
| "type": "service_account", | |
| "project_id": os.getenv("FIREBASE_PROJECT_ID"), | |
| "private_key": os.getenv("FIREBASE_PRIVATE_KEY").replace('\\n', '\n'), | |
| "client_email": os.getenv("FIREBASE_CLIENT_EMAIL"), | |
| "token_uri": "https://oauth2.googleapis.com/token", | |
| }) | |
| firebase_admin.initialize_app(cred) | |
| db = firestore.client() | |
| def home(): | |
| return "Carpool Backend is Live on Hugging Face!" | |
| def get_rides(): | |
| rides_ref = db.collection('rides').stream() | |
| rides = [doc.to_dict() for doc in rides_ref] | |
| return jsonify(rides) | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |