Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,39 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
| 14 |
-
json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import socket
|
| 3 |
+
import os
|
| 4 |
+
from datetime import datetime
|
| 5 |
+
import boto3
|
| 6 |
|
| 7 |
+
# Initialize boto3 S3 client
|
| 8 |
+
s3 = boto3.client('s3')
|
| 9 |
|
| 10 |
+
def Create_Organization(org_name, org_handle):
|
| 11 |
+
on = org_name
|
| 12 |
+
o=org_handle
|
| 13 |
+
path = o
|
| 14 |
+
isExist = os.path.exists(path)
|
| 15 |
+
hostname=socket.gethostname()
|
| 16 |
+
now = datetime.now()
|
| 17 |
+
tim=now.strftime("%d/%m/%Y %H:%M:%S")
|
| 18 |
+
Organizationdetails={}
|
| 19 |
+
Organization_required_details = ["Organizationame","OrganizationHandle" "Created_by", "Created_Time"]
|
| 20 |
+
Organizationdetails[org_handle] = {}
|
| 21 |
+
Organizationdetails[org_handle]['Organizationame']=org_name
|
| 22 |
+
Organizationdetails[org_handle]['OrganizationHandle']=org_handle
|
| 23 |
+
Organizationdetails[org_handle]['Created_by']=hostname
|
| 24 |
+
Organizationdetails[org_handle]['Created_Time']=tim
|
| 25 |
|
| 26 |
+
# Save the organization details to S3 bucket
|
| 27 |
+
bucket = s3.Bucket('orgbotrite')
|
| 28 |
+
key = 'Organizations/' + org_handle + '/Organizationdetails.json'
|
| 29 |
+
blob = bucket.put_object(Key=key, Body=json.dumps(Organizationdetails))
|
| 30 |
+
|
| 31 |
+
return "Organization Created : "+ o
|
| 32 |
+
|
| 33 |
+
import gradio as gr
|
| 34 |
+
inputs = [
|
| 35 |
+
gr.inputs.Textbox(label="Organization Name"),
|
| 36 |
+
gr.inputs.Textbox(label="Organization Handle"),
|
| 37 |
+
]
|
| 38 |
+
outputs = gr.outputs.Textbox(label="Message")
|
| 39 |
+
gr.Interface(Create_Organization, inputs, outputs).launch()
|