Update app.py
Browse files12345678910111213import gradio as grimport os# Function to serve the HTML filedef serve_html():with open("index.html", "r") as file:return file.read()# Create a Gradio Interfaceiface = gr.Interface(fn=serve_html, inputs=None, outputs="html", live=True)# Launch the Gradio appiface.launch()1234567891011121314151617181920212223242526272829303132import gradio as grimport os# Function to handle image upload and layout settingdef process_images(layout, image_files):# Save uploaded imagesimg_paths = []for img_file in image_files:img_path = f"temp_images/{img_file.name}"img_file.save(img_path)img_paths.append(img_path)# Return the layout and image paths to the front-end (HTML and JS will take care of it)return layout, img_paths# Gradio Interface setupiface = gr.Interface(fn=process_images,inputs=[gr.Dropdown(label="Choose Grid Layout",choices=["1x2", "1x3", "1x4", "2x2", "2x3", "random", "jagged4", "split6", "chaos5"],default="3x3"),gr.File(label="Upload Images", type="file", multiple=True) # Multiple image upload],outputs=["text", "json"], # We'll output a layout and list of image pathslive=True # Updates in real-time)# Run Gradio appiface.launch(share=True)
app.py+27-8