import gradio as gr import requests import os def invite_user(username): GITHUB_TOKEN = os.getenv('GITHUB_TOKEN') GITHUB_ORG = os.getenv('GITHUB_ORG') headers = { 'Authorization': f'token {GITHUB_TOKEN}', 'Accept': 'application/vnd.github.v3+json', 'Content-Type': 'application/json', } data = {'invitee_id': username} response = requests.post( f'https://api.github.com/orgs/{GITHUB_ORG}/invitations', headers=headers, json=data ) if response.status_code == 201: return f'Invitation sent to {username}' else: return f'Error: {response.json().get("message", "Unknown error")}' iface = gr.Interface( fn=invite_user, inputs=gr.inputs.Textbox(label="GitHub Username"), outputs=gr.outputs.Textbox(label="Response"), title='Join AccioINTERN', description='Enter your GitHub username to receive an invitation to join the AccioINTERN organization.' ) if __name__ == "__main__": iface.launch()