Minahel commited on
Commit
63e3b8c
Β·
verified Β·
1 Parent(s): 2028181

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -13,7 +13,7 @@ if not os.path.exists(NOTES_FILE):
13
  # -------- Core Functions -------- #
14
 
15
  def add_note(title, content):
16
- if title.strip() == "" or content.strip() == "":
17
  return "⚠️ Title and content cannot be empty!", get_notes()
18
 
19
  timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -33,6 +33,9 @@ def add_note(title, content):
33
 
34
 
35
  def get_notes():
 
 
 
36
  with open(NOTES_FILE, "r", encoding="utf-8") as f:
37
  data = f.read()
38
 
@@ -64,11 +67,11 @@ with gr.Blocks(
64
  <p style="text-align:center; font-size:18px;">
65
  Beautiful β€’ Organized β€’ Simple β€’ Powerful
66
  </p>
67
- """,
68
  )
69
 
70
  with gr.Row():
71
- with gr.Column(scale=1):
72
  gr.Markdown("### ✍️ Create a New Note")
73
 
74
  title_input = gr.Textbox(
@@ -90,7 +93,7 @@ with gr.Blocks(
90
  interactive=False
91
  )
92
 
93
- with gr.Column(scale=1):
94
  gr.Markdown("### πŸ“š Your Notes")
95
 
96
  notes_display = gr.Textbox(
@@ -101,7 +104,7 @@ with gr.Blocks(
101
  refresh_btn = gr.Button("πŸ”„ Refresh Notes")
102
  download_btn = gr.DownloadButton("πŸ“₯ Download Notes")
103
 
104
- # Button Interactions
105
  add_btn.click(
106
  add_note,
107
  inputs=[title_input, content_input],
@@ -126,4 +129,6 @@ with gr.Blocks(
126
  demo.load(get_notes, outputs=notes_display)
127
 
128
 
129
- demo.launch(server_name="0.0.0.0")
 
 
 
13
  # -------- Core Functions -------- #
14
 
15
  def add_note(title, content):
16
+ if not title.strip() or not content.strip():
17
  return "⚠️ Title and content cannot be empty!", get_notes()
18
 
19
  timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
 
33
 
34
 
35
  def get_notes():
36
+ if not os.path.exists(NOTES_FILE):
37
+ return "✨ No notes yet."
38
+
39
  with open(NOTES_FILE, "r", encoding="utf-8") as f:
40
  data = f.read()
41
 
 
67
  <p style="text-align:center; font-size:18px;">
68
  Beautiful β€’ Organized β€’ Simple β€’ Powerful
69
  </p>
70
+ """
71
  )
72
 
73
  with gr.Row():
74
+ with gr.Column():
75
  gr.Markdown("### ✍️ Create a New Note")
76
 
77
  title_input = gr.Textbox(
 
93
  interactive=False
94
  )
95
 
96
+ with gr.Column():
97
  gr.Markdown("### πŸ“š Your Notes")
98
 
99
  notes_display = gr.Textbox(
 
104
  refresh_btn = gr.Button("πŸ”„ Refresh Notes")
105
  download_btn = gr.DownloadButton("πŸ“₯ Download Notes")
106
 
107
+ # Button Actions
108
  add_btn.click(
109
  add_note,
110
  inputs=[title_input, content_input],
 
129
  demo.load(get_notes, outputs=notes_display)
130
 
131
 
132
+ # πŸ”₯ IMPORTANT FIX FOR HUGGING FACE
133
+ if __name__ == "__main__":
134
+ demo.launch()