Spaces:
Sleeping
Sleeping
File size: 1,713 Bytes
ac52741 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | import gradio as gr
# Original code snippet
# def merge_sort(arr):
# if len(arr) <= 1:
# return arr
#
# mid = len(arr) // 2
# left = merge_sort(arr[:mid])
# right = merge_sort(arr[mid:])
#
# return merge(left, right)
#
#
# def merge(left, right):
# result = []
# i = j = 0
#
# while i < len(left) and j < len(right):
# if left[i] <= right[j]:
# result.append(left[i])
# i += 1
# else:
# result.append(right[j])
# j += 1
#
# result.extend(left[i:])
# result.extend(right[j:])
# return result
#
#
# # Example usage
# numbers = [38, 27, 43, 3, 9, 82, 10]
# sorted_numbers = merge_sort(numbers)
#
# print("Original:", numbers)
# print("Sorted:", sorted_numbers)
# Gradio interface
def process_input(input_text):
try:
# Process the input
return f"Processed: {input_text}"
except Exception as e:
return f"Error: {str(e)}"
# Create the Gradio app
with gr.Blocks(title="Generated Application", theme=gr.themes.Soft()) as demo:
gr.Markdown("# Generated Application")
with gr.Row():
with gr.Column():
input_box = gr.Textbox(
label="Input Text",
placeholder="Enter text to process...",
lines=3
)
submit_btn = gr.Button("Process", variant="primary")
with gr.Row():
output_box = gr.Textbox(
label="Output",
interactive=False,
lines=5
)
submit_btn.click(
fn=process_input,
inputs=[input_box],
outputs=[output_box]
)
if __name__ == "__main__":
demo.launch(share=False)
|