3D-Viewer / modules /constants.py
Surn's picture
Add shortened URL and Open Graph
4e27a59
# modules/constants.py
# constants.py contains all the constants used in the project
import os
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables from .env file
dotenv_path = Path(__file__).parent.parent / '.env'
load_dotenv(dotenv_path)
IS_SHARED_SPACE = "Surn/3D-Viewer" in os.environ.get('SPACE_ID', '')
HF_API_TOKEN = os.getenv("HF_TOKEN")
if not HF_API_TOKEN:
raise ValueError("HF_TOKEN is not set. Please check your .env file.")
try:
if os.environ['TMPDIR']:
TMPDIR = os.environ['TMPDIR']
else:
TMPDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
except:
TMPDIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
os.makedirs(TMPDIR, exist_ok=True)
model_extensions = {".glb", ".gltf", ".obj", ".ply"}
model_extensions_list = list(model_extensions)
image_extensions = {".png", ".jpg", ".jpeg", ".webp"}
image_extensions_list = list(image_extensions)
upload_file_types = model_extensions_list + image_extensions_list
default_slider_images = [
"images/slider/beeuty_545jlbh1_v12_alpha96_300dpi.png",
"images/slider/beeuty_545jlbh1_v12_alpha96_300dpi_depth.png"
]
default_model_3d = "models/beeuty_545jlbh1_300dpi.glb"
# Constants for URL shortener
HF_REPO_ID = "Surn/Storage" # Replace with your Hugging Face repository ID
SHORTENER_JSON_FILE = "shortener.json" # The name of your JSON file in the repo
# Open Graph Defaults
APP_BASE_URL = "https://surn-3d-viewer.hf.space" # Replace if your app URL is different
DEFAULT_OG_TITLE = "3D Viewer"
DEFAULT_OG_DESCRIPTION = "View and share 3D models and images interactively."
DEFAULT_OG_IMAGE_URL = APP_BASE_URL + "/gradio_api/file=" + default_slider_images[0]
DEFAULT_OG_TYPE = "website"