You run it and show the screen i can't able to run the file if i run http://127.0.0.1:8000/ ID Name Users Tech Stack @router.get("/", summary="List Functions", description="List all functions for a module.") async def list_functions( request: Request, module_id: str = Path(..., description="The ID of the module"), search: Optional[str] = Query(None, description="Search term for filtering functions") ): try: logger.debug(f"Received request: {request.url}") logger.debug(f"Request headers: {request.headers}") # Get database and modules collection db, modules_collection = get_database() # Verify if the module exists module = modules_collection.find_one({"ID": module_id}) logger.debug(f"Module retrieved: {module}") if not module: logger.error(f"Module with ID {module_id} not found") raise HTTPException(status_code=404, detail="Module not found") # Access the functions field functions = module.get("scope",{}).get("results", {}).get("functions", []) logger.debug(f"Module results: {module.get('results')}") logger.debug(f"Functions: {functions}") # Check if functions are present if not functions: logger.warning(f"No functions found for module ID: {module_id}") return JSONResponse( content={"total": 0, "functions": []}, headers={ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", "Access-Control-Allow-Headers": "*", "Content-Type": "application/json" } ) # Apply search filter if provided if search: functions = [ func for func in functions if search.lower() in func.get("name", "").lower() or search.lower() in func.get("description", "").lower() ] logger.debug(f"Functions after applying search filter: {functions}") # Convert ObjectId fields to strings functions = convert_objectid_to_str(functions) # Build response with only name, description, and ID of each function response_data = [ { "name": func.get("name", ""), "description": func.get("description", ""), "ID": func.get("ID", "") # IDs are now strings } for func in functions ] logger.debug(f"Successfully retrieved {len(response_data)} functions") # Prepare the response data with the total count return JSONResponse( content={"total": len(response_data), "functions": response_data}, headers={ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", "Access-Control-Allow-Headers": "*", "Content-Type": "application/json" } ) except Exception as e: logger.error(f"Error listing functions: {str(e)}", exc_info=True) raise HTTPException(status_code=500, detail=str(e)) ========================>back up lisiting all the features ======> against the module @router.get("/{function_id}/features", response_model=FeatureList, summary="List Features", description="List all features for a function.") async def list_features( request: Request, function_id: str = Path(..., description="The ID of the function"), module_id: str = Path(..., description="The ID of the module"), search: Optional[str] = Query(None, description="Search term for filtering functions") ): """ List all features for a function. """ try: logger.debug(f"Listing features for function ID: {function_id} in module ID: {module_id}") # Get database and modules collection db, modules_collection = get_database() # Fetch the module data from the database module = modules_collection.find_one({ "ID": module_id, }) print("module==========>", module) if not module: logger.error(f"Module with ID {module_id} not found") raise HTTPException(status_code=404, detail="Module not found") # Extract the functions list functions = module.get("scope", {}).get("results", {}).get("functions", []) logger.debug(f"Functions: {functions}") # Check if functions are present if not functions: logger.warning(f"No functions found for module ID: {module_id}") return JSONResponse( content={"total": 0, "features": []}, headers={ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", "Access-Control-Allow-Headers": "*", "Content-Type": "application/json" } ) # Now, extract features from each function features = [] for function in functions: # Extract features from the function function_features = function.get("features", []) # Apply search filter if provided if search: function_features = [ feature for feature in function_features if search.lower() in feature.get("name", "").lower() or search.lower() in feature.get("description", "").lower() ] # Append the filtered features features.extend(function_features) # Convert ObjectId fields to strings features = convert_objectid_to_str(features) # Build the response with only name, description, and ID of each feature response_data = [ { "name": feature.get("name", ""), "description": feature.get("description", ""), "ID": feature.get("ID", "") # IDs are now strings } for feature in features ] logger.debug(f"Successfully retrieved {len(response_data)} features") # Prepare the response data with the total count return JSONResponse( content={"total": len(response_data), "features": response_data}, headers={ "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", "Access-Control-Allow-Headers": "*", "Content-Type": "application/json" } ) except Exception as e: logger.error(f"Error listing features: {str(e)}", exc_info=True) raise HTTPException(status_code=500, detail=str(e))