Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Path to CSV file
|
| 6 |
-
CSV_FILE = "patients.csv"
|
| 7 |
|
| 8 |
# Initialize the CSV file if it does not exist
|
| 9 |
if not os.path.exists(CSV_FILE):
|
|
@@ -29,8 +29,13 @@ def register_patient(name, age, phone):
|
|
| 29 |
file.flush()
|
| 30 |
os.fsync(file.fileno()) # Force writing to disk
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
| 33 |
except Exception as e:
|
|
|
|
|
|
|
| 34 |
return f"An error occurred: {e}"
|
| 35 |
|
| 36 |
# Define Gradio interface
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Path to CSV file
|
| 6 |
+
CSV_FILE = os.path.join(os.getcwd(), "patients.csv")
|
| 7 |
|
| 8 |
# Initialize the CSV file if it does not exist
|
| 9 |
if not os.path.exists(CSV_FILE):
|
|
|
|
| 29 |
file.flush()
|
| 30 |
os.fsync(file.fileno()) # Force writing to disk
|
| 31 |
|
| 32 |
+
# Additional logging to check if write was successful
|
| 33 |
+
print(f"Data successfully written to {CSV_FILE}")
|
| 34 |
+
|
| 35 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
| 36 |
except Exception as e:
|
| 37 |
+
# Return error message and print stack trace for debugging
|
| 38 |
+
print(f"An error occurred: {e}")
|
| 39 |
return f"An error occurred: {e}"
|
| 40 |
|
| 41 |
# Define Gradio interface
|