Rahul8827 commited on
Commit
f429b1b
·
1 Parent(s): 9b63352

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -11
app.py CHANGED
@@ -1,14 +1,39 @@
1
- import transformers
 
 
 
 
2
 
3
- # create a hugging face space client
4
- client = transformers.Client()
5
 
6
- # create a new organization
7
- organization = client.create_organization(
8
- name="My Organization",
9
- handle="my-organization",
10
- )
 
 
 
 
 
 
 
 
 
 
11
 
12
- # save the organization to a json file
13
- with open("organization.json", "w") as f:
14
- json.dump(organization, f)
 
 
 
 
 
 
 
 
 
 
 
 
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()