Spaces:
Build error
Build error
| import json | |
| import socket | |
| import os | |
| from datetime import datetime | |
| import boto3 | |
| def Create_Organization(org_name, org_handle): | |
| on = org_name | |
| o=org_handle | |
| path = o | |
| isExist = os.path.exists(path) | |
| hostname=socket.gethostname() | |
| now = datetime.now() | |
| tim=now.strftime("%d/%m/%Y %H:%M:%S") | |
| Organizationdetails={} | |
| Organization_required_details = ["Organizationame","OrganizationHandle" "Created_by", "Created_Time"] | |
| Organizationdetails[org_handle] = {} | |
| Organizationdetails[org_handle]['Organizationame']=org_name | |
| Organizationdetails[org_handle]['OrganizationHandle']=org_handle | |
| Organizationdetails[org_handle]['Created_by']=hostname | |
| Organizationdetails[org_handle]['Created_Time']=tim | |
| # Create a bucket in S3 | |
| s3 = boto3.client('s3') | |
| bucket = s3.create_bucket(Bucket='orgbotrite23') | |
| # Save the organization details to S3 bucket | |
| key = 'Organizations/' + org_handle + '/Organizationdetails.json' | |
| blob = bucket.put_object(Key=key, Body=json.dumps(Organizationdetails)) | |
| return "Organization Created : "+ o | |
| import gradio as gr | |
| inputs = [ | |
| gr.inputs.Textbox(label="Organization Name"), | |
| gr.inputs.Textbox(label="Organization Handle"), | |
| ] | |
| outputs = gr.outputs.Textbox(label="Message") | |
| gr.Interface(Create_Organization, inputs, outputs).launch() |