trexhere commited on
Commit
4ad2293
1 Parent(s): b677bde

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import os
4
+
5
+ def invite_user(username):
6
+ GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
7
+ GITHUB_ORG = os.getenv('GITHUB_ORG')
8
+ headers = {
9
+ 'Authorization': f'token {GITHUB_TOKEN}',
10
+ 'Accept': 'application/vnd.github.v3+json',
11
+ 'Content-Type': 'application/json',
12
+ }
13
+ data = {'invitee_id': username}
14
+
15
+ response = requests.post(
16
+ f'https://api.github.com/orgs/{GITHUB_ORG}/invitations',
17
+ headers=headers,
18
+ json=data
19
+ )
20
+
21
+ if response.status_code == 201:
22
+ return f'Invitation sent to {username}'
23
+ else:
24
+ return f'Error: {response.json().get("message", "Unknown error")}'
25
+
26
+ iface = gr.Interface(
27
+ fn=invite_user,
28
+ inputs=gr.inputs.Textbox(label="GitHub Username"),
29
+ outputs=gr.outputs.Textbox(label="Response"),
30
+ title='Join AccioINTERN',
31
+ description='Enter your GitHub username to receive an invitation to join the AccioINTERN organization.'
32
+ )
33
+
34
+ if __name__ == "__main__":
35
+ iface.launch()