Rahul8827 commited on
Commit
030ce18
·
1 Parent(s): 8fe1db9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -32,7 +32,7 @@ def Create_Organization(org_name, org_handle):
32
 
33
  return "Organization Created: " + o
34
 
35
- def list_s3_folders():
36
  s3_client = boto3.client('s3')
37
  bucket_name = 'myorg'
38
 
@@ -40,18 +40,23 @@ def list_s3_folders():
40
 
41
  folders = [o.get('Prefix') for o in result.get('CommonPrefixes')]
42
  return "\n".join(folders)
43
-
44
- inputs_create_org = [
45
- gr.inputs.Textbox(label="Organization Name"),
46
- gr.inputs.Textbox(label="Organization Handle"),
47
- ]
48
- outputs_create_org = gr.outputs.Textbox(label="Message")
49
-
50
- inputs_list_folders = None
51
- outputs_list_folders = gr.outputs.Textbox(label="S3 Folders")
52
-
53
- iface_create_org = gr.Interface(Create_Organization, inputs_create_org, outputs_create_org)
54
- iface_list_folders = gr.Interface(list_s3_folders, inputs_list_folders, outputs_list_folders)
55
-
56
- iface_create_org.launch()
57
- iface_list_folders.launch()
 
 
 
 
 
 
32
 
33
  return "Organization Created: " + o
34
 
35
+ def list_of_organization():
36
  s3_client = boto3.client('s3')
37
  bucket_name = 'myorg'
38
 
 
40
 
41
  folders = [o.get('Prefix') for o in result.get('CommonPrefixes')]
42
  return "\n".join(folders)
43
+ def main_function(action, org_name=None, org_handle=None):
44
+ if action == "Create Organization":
45
+ return Create_Organization(org_name, org_handle)
46
+ elif action == "list_of_organization":
47
+ return list_s3_folders()
48
+
49
+ interface = gr.Interface(
50
+ fn=main_function,
51
+ inputs=[
52
+ gr.inputs.Dropdown(
53
+ choices=["Create Organization", "list_of_organization"],
54
+ label="Select an Action"
55
+ ),
56
+ gr.inputs.Textbox(label="Organization Name"),
57
+ gr.inputs.Textbox(label="Organization Handle"),
58
+ ],
59
+ outputs=gr.outputs.Textbox(label="Message"),
60
+ )
61
+
62
+ interface.launch()