Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
CSV_FILE = "
|
| 7 |
|
| 8 |
# Initialize the CSV file if it does not exist
|
| 9 |
if not os.path.exists(CSV_FILE):
|
|
@@ -26,6 +26,8 @@ def register_patient(name, age, phone):
|
|
| 26 |
# Save updated data
|
| 27 |
with open(CSV_FILE, 'w') as file:
|
| 28 |
df.to_csv(file, index=False)
|
|
|
|
|
|
|
| 29 |
|
| 30 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
| 31 |
except Exception as e:
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
# Path to CSV file in the root directory of your project
|
| 6 |
+
CSV_FILE = "patients.csv"
|
| 7 |
|
| 8 |
# Initialize the CSV file if it does not exist
|
| 9 |
if not os.path.exists(CSV_FILE):
|
|
|
|
| 26 |
# Save updated data
|
| 27 |
with open(CSV_FILE, 'w') as file:
|
| 28 |
df.to_csv(file, index=False)
|
| 29 |
+
file.flush()
|
| 30 |
+
os.fsync(file.fileno()) # Ensure data is written to disk
|
| 31 |
|
| 32 |
return f"Patient {name} with ID {new_id} registered successfully!"
|
| 33 |
except Exception as e:
|