Spaces:
Sleeping
Sleeping
import gradio as gr | |
import requests | |
def request_url(url): | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' | |
'Chrome/88.0.4324.146 Safari/537.36', | |
} | |
try: | |
response = requests.get(url=url, headers=headers) | |
if response.status_code == 200: | |
return response.text | |
except requests.RequestException: | |
return None | |
import os | |
def greet(name): | |
url = f'https://huggingface.co/spaces?p=1&sort=modified&search=GPT' | |
html = request_url(url) | |
key = os.getenv("OPENAI_API_KEY") | |
return "Hello " + key + "!!" | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() |