Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
import os | |
def invite_user(username): | |
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN') | |
GITHUB_ORG = os.getenv('GITHUB_ORG') | |
response = requests.post( | |
f'https://api.github.com/orgs/{GITHUB_ORG}/invitations', | |
headers={ | |
'Authorization': f'token {GITHUB_TOKEN}', | |
'Accept': 'application/vnd.github.v3+json', | |
'Content-Type': 'application/json', | |
}, | |
json={'invitee_id': username} | |
) | |
if response.ok: | |
return f'Invitation sent to {username}' | |
else: | |
return f'Error: {response.json().get("message", "Unknown error")}' | |
iface = gr.Interface( | |
fn=invite_user, | |
inputs='text', | |
outputs='text', | |
title='Join AccioINTERN' | |
) | |
if __name__ == "__main__": | |
iface.launch() | |