Spaces:
Sleeping
Sleeping
import gradio as gr | |
import os | |
def get_space_info(): | |
# Using the specific environment variables for Hugging Face Spaces | |
space_host = os.getenv("SPACE_HOST", "Unknown") | |
space_author_name = os.getenv("SPACE_AUTHOR_NAME", "Unknown") | |
space_repo_name = os.getenv("SPACE_REPO_NAME", "Unknown") | |
if space_host != "Unknown": | |
return ( | |
f"Running on Hugging Face Space: {space_author_name}/{space_repo_name}\n" | |
f"Space Host URL: {space_host}" | |
) | |
else: | |
return "Not running on a Hugging Face Space or environment variables are not set." | |
# Creating the Gradio interface | |
interface = gr.Interface( | |
fn=get_space_info, | |
inputs=[], | |
outputs="text", | |
title="Hugging Face Space Info Checker" | |
) | |
# Launching the Gradio interface | |
if __name__ == "__main__": | |
interface.launch() | |