Skip to content

Commit 756e844

Browse files
committed
remove encode id and password
1 parent a843148 commit 756e844

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

app/main.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import List
44
from pydantic import BaseModel
55
import motor.motor_asyncio
6-
from urllib.parse import quote_plus
76

87
app = FastAPI(
98
title="Fastapi and mongodb demo API",
@@ -20,16 +19,12 @@
2019
print(f"mongodb_user : {mongodb_user}")
2120
print(f"mongodb_password : {mongodb_password}")
2221

23-
# Encode username & password
24-
encoded_user = quote_plus(mongodb_user)
25-
encoded_password = quote_plus(mongodb_password)
26-
2722
# Construct the MongoDB URI
2823
if "@" in raw_mongodb_url:
2924
# If DB_URL already contains credentials, use it as is
3025
mongodb_url = raw_mongodb_url
3126
else:
32-
mongodb_url = f"mongodb://{encoded_user}:{encoded_password}@{raw_mongodb_url.split('mongodb://')[1]}"
27+
mongodb_url = f"mongodb://{mongodb_user}:{mongodb_password}@{raw_mongodb_url.split('mongodb://')[1]}"
3328

3429
print(f"Using MongoDB URL: {mongodb_url}")
3530

0 commit comments

Comments
 (0)