rohanshaw commited on
Commit
cd325a1
·
1 Parent(s): ef16e35

Update api.py

Browse files
Files changed (1) hide show
  1. api.py +4 -4
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 json
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 = "mongodb+srv://rohanshaw-1-authdata:Rohan05@authdata.j4kqwl4.mongodb.net/?retryWrites=true&w=majority"
16
- DATABASE_NAME = "AuthData"
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("/get_all_users")
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