Spaces:
Build error
Build error
Download app.py from lemonshark998/hackaithon101: direct link, hf CLI and curl.
- Browser
- Download file 633 Bytes
-
https://huggingface.co/spaces/lemonshark998/hackaithon101/resolve/main/app.py
- Command line
-
hf download hf://spaces/lemonshark998/hackaithon101/app.py
-
curl -L -o app.py https://huggingface.co/spaces/lemonshark998/hackaithon101/resolve/main/app.py
633 Bytes
| import gradio as gr | |
| import requests | |
| import os | |
| os.environ['HACKAITHONBEARERTOKEN'] = "Bearer <project>" | |
| API_URL = "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment" | |
| bt = os.environ['HACKAITHONBEARERTOKEN'] | |
| headers = {"Authorization": bt } | |
| def query(data): | |
| response = requests.post(API_URL, headers=headers, json=data) | |
| return "V2"+str(response.json()) | |
| def greet(howareyoufeeling): | |
| output = query({"inputs":howareyoufeeling}) | |
| print (str(output)) | |
| return str(output) | |
| iface = gr.Interface( | |
| fn=greet, inputs=["text"], outputs="text", allow_flagging="never") | |
| iface.launch() | |