trexhere commited on
Commit
7514ed6
1 Parent(s): c825180

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ response = requests.post(
9
+ f'https://api.github.com/orgs/{GITHUB_ORG}/invitations',
10
+ headers={
11
+ 'Authorization': f'token {GITHUB_TOKEN}',
12
+ 'Accept': 'application/vnd.github.v3+json',
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ json={'invitee_id': username}
16
+ )
17
+
18
+ if response.ok:
19
+ return f'Invitation sent to {username}'
20
+ else:
21
+ return f'Error: {response.json().get("message", "Unknown error")}'
22
+
23
+ iface = gr.Interface(
24
+ fn=invite_user,
25
+ inputs='text',
26
+ outputs='text',
27
+ title='Join AccioINTERN'
28
+ )
29
+
30
+ if __name__ == "__main__":
31
+ iface.launch()