Download app.py from sscnitdgp/test: direct link, hf CLI and curl.
- Browser
- Download file 783 Bytes
-
https://huggingface.co/spaces/sscnitdgp/test/resolve/main/app.py
- Command line
-
hf download hf://spaces/sscnitdgp/test/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sscnitdgp/test/resolve/main/app.py
783 Bytes
| import gradio as gr | |
| import requests | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| def check_carbon_intensity(name: str) -> dict: | |
| """ | |
| Help get carbon intensity from interesting places | |
| Args: | |
| name (str): name of the place | |
| Returns: | |
| dict: dictionary | |
| """ | |
| "" | |
| headers = { | |
| "Authorization": f"Bearer XXXXXXXXX" | |
| } | |
| try: | |
| response = requests.get('httpsmmmmmNSW', headers=headers) | |
| response.raise_for_status() # Raise an exception for HTTP errors | |
| return response.json() | |
| except requests.exceptions.RequestException as e: | |
| print(f"An error occurred: {e}") | |
| return None | |
| demo = gr.Interface(fn=check_carbon_intensity, inputs="text", outputs=gr.JSON()) | |
| demo.launch(mcp_server=True) | |