| import gradio as gr | |
| import requests | |
| import os | |
| def function1(user, message, code, option): | |
| token = os.environ.get("token") | |
| Code = os.environ.get("code") | |
| userID = os.environ.get("userID") | |
| if code == Code: | |
| endpoint = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={userID}&text={user} asked: {message} to JohnAI. Mode: {option}" | |
| send_response = requests.post(endpoint) | |
| return "Done" | |
| else: | |
| return "Failed" | |
| inputs = [ | |
| gr.inputs.Textbox(label="Textbox1",type="text"), | |
| gr.inputs.Textbox(label="Textbox2",type="text"), | |
| gr.inputs.Textbox(label="Textbox3",type="password"), | |
| gr.inputs.Textbox(label="Textbox4",type="text") | |
| ] | |
| iface = gr.Interface(fn=function1, inputs=inputs, outputs="text") | |
| iface.launch() |