yougandar commited on
Commit
af7b605
·
verified ·
1 Parent(s): ee6ae7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
2
  import pandas as pd
3
  import os
4
 
5
- # Use /tmp directory for Hugging Face Spaces
6
- CSV_FILE = "/tmp/patients.csv"
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: