Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
@@ -3,7 +3,7 @@ import cv2
|
|
3 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Form, Depends
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
import numpy as np
|
6 |
-
import
|
7 |
import datetime
|
8 |
import base64
|
9 |
from motor.motor_asyncio import AsyncIOMotorClient
|
@@ -12,8 +12,8 @@ from pymongo.server_api import ServerApi
|
|
12 |
app = FastAPI()
|
13 |
|
14 |
# MongoDB connection settings
|
15 |
-
MONGODB_URL =
|
16 |
-
DATABASE_NAME = "
|
17 |
COLLECTION_NAME = "inkognitoUsers"
|
18 |
|
19 |
# Allowing CORS (Cross-Origin Resource Sharing)
|
@@ -174,7 +174,7 @@ async def save_user_data(name: str = Form(...), email: str = Form(...), database
|
|
174 |
except Exception as e:
|
175 |
raise HTTPException(status_code=500, detail=str(e))
|
176 |
|
177 |
-
@app.get("
|
178 |
async def get_all_users(database: AsyncIOMotorClient = Depends(get_database_client)):
|
179 |
try:
|
180 |
# Retrieve all users from MongoDB
|
|
|
3 |
from fastapi import FastAPI, File, UploadFile, HTTPException, Form, Depends
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
import numpy as np
|
6 |
+
import os
|
7 |
import datetime
|
8 |
import base64
|
9 |
from motor.motor_asyncio import AsyncIOMotorClient
|
|
|
12 |
app = FastAPI()
|
13 |
|
14 |
# MongoDB connection settings
|
15 |
+
MONGODB_URL = os.environ.get("mongoUrl")
|
16 |
+
DATABASE_NAME = os.environ.get("databaseName")
|
17 |
COLLECTION_NAME = "inkognitoUsers"
|
18 |
|
19 |
# Allowing CORS (Cross-Origin Resource Sharing)
|
|
|
174 |
except Exception as e:
|
175 |
raise HTTPException(status_code=500, detail=str(e))
|
176 |
|
177 |
+
@app.get(os.environ.get("getUsersEp"))
|
178 |
async def get_all_users(database: AsyncIOMotorClient = Depends(get_database_client)):
|
179 |
try:
|
180 |
# Retrieve all users from MongoDB
|