Infinity-1995 commited on
Commit
10cf8a4
·
verified ·
1 Parent(s): 078805c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -109,11 +109,11 @@ def generate_itinerary(mood, location, budget, days):
109
  # Generate map HTML from itinerary text and user location
110
  map_html = extract_places_and_map(itinerary_text, city_context=location_text if location_text.lower() != "any destination" else None)
111
 
112
- return itinerary_text, image_path, map_html
113
 
114
  def generate_pdf(itinerary_text):
115
  if not itinerary_text.strip():
116
- return None
117
 
118
  temp_dir = tempfile.gettempdir()
119
  temp_path = os.path.join(temp_dir, "feelaway_itinerary.pdf")
@@ -142,7 +142,7 @@ def generate_pdf(itinerary_text):
142
 
143
  doc.build(story)
144
 
145
- return temp_path
146
 
147
 
148
  with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")) as demo:
@@ -182,24 +182,24 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")
182
 
183
  with gr.Row():
184
  with gr.Column():
185
- image_output = gr.Image(label="Travel Mood Image", type="filepath", visible=True)
186
  with gr.Column():
187
- map_output = gr.HTML(label="Map of Suggested Places", elem_id="map-container")
188
 
189
  with gr.Column():
190
- download_btn = gr.Button("Download Itinerary as PDF", variant="secondary")
191
- pdf_file = gr.File(label="Download PDF", file_types=[".pdf"])
192
 
193
  generate_btn.click(
194
  generate_itinerary,
195
  inputs=[mood, location, budget, days],
196
- outputs=[itinerary_output, image_output, map_output],
197
  show_progress=True
198
  )
199
  download_btn.click(
200
  generate_pdf,
201
  inputs=[itinerary_output],
202
- outputs=pdf_file
203
  )
204
 
205
  demo.launch()
 
109
  # Generate map HTML from itinerary text and user location
110
  map_html = extract_places_and_map(itinerary_text, city_context=location_text if location_text.lower() != "any destination" else None)
111
 
112
+ return itinerary_text, image_path, map_html,gr.update(visible=True)
113
 
114
  def generate_pdf(itinerary_text):
115
  if not itinerary_text.strip():
116
+ return None,gr.update(visible=False)
117
 
118
  temp_dir = tempfile.gettempdir()
119
  temp_path = os.path.join(temp_dir, "feelaway_itinerary.pdf")
 
142
 
143
  doc.build(story)
144
 
145
+ return temp_path,gr.update(visible=True)
146
 
147
 
148
  with gr.Blocks(theme=gr.themes.Default(primary_hue="teal", secondary_hue="teal")) as demo:
 
182
 
183
  with gr.Row():
184
  with gr.Column():
185
+ image_output = gr.Image(label="Travel Mood Image",type="filepath", visible=False)
186
  with gr.Column():
187
+ map_output = gr.HTML(label="Map of Suggested Places",elem_id="map-container")
188
 
189
  with gr.Column():
190
+ download_btn = gr.Button("Download Itinerary as PDF",variant="secondary")
191
+ pdf_file = gr.File(label="Download PDF", file_types=[".pdf"],visible=False)
192
 
193
  generate_btn.click(
194
  generate_itinerary,
195
  inputs=[mood, location, budget, days],
196
+ outputs=[itinerary_output, image_output, map_output, image_output],
197
  show_progress=True
198
  )
199
  download_btn.click(
200
  generate_pdf,
201
  inputs=[itinerary_output],
202
+ outputs=[pdf_file, pdf_file]
203
  )
204
 
205
  demo.launch()