API_KEY_NonLoggedInUsers = os.getenv("API_KEY_NonLoggedInUsers") API_KEY_NAME_NonLoggedInUsers = "access_token_NonLoggedInUsers" api_key_header_NonLoggedInUsers = APIKeyHeader(name=API_KEY_NAME_NonLoggedInUsers, auto_error=True)
app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], )
def get_api_key_NonLoggedInUser(api_key_header: str = Security(api_key_header_NonLoggedInUsers)): if api_key_header == API_KEY_NonLoggedInUsers: return api_key_header else: raise HTTPException( status_code=HTTP_403_FORBIDDEN, detail="Could not validate credentials" )
@app.post("/get_answers_NonLoggedInUser", response_description="The response to the user's question.", responses=example_responses_get_answer_NonLoggedInUser) async def get_answers( api_key: str = Depends(get_api_key_NonLoggedInUser), device_id: str = Body(..., description="The ID of the device making the request. If the device ID doesn't exist in the database, a new user will be created with the same device ID inputted."), user_question: str = Body(..., description="The question asked by the user.") ) -> dict:
I tried everything and nothing worked
Adhi Vp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.