mouse-webgen / app.py
openfree's picture
Update app.py
93eafd0 verified
raw
history blame
1.25 kB
import re
import random
from http import HTTPStatus
from typing import Dict, List, Optional, Tuple
import base64
import anthropic
import openai
import asyncio
import time
from functools import partial
import json
import gradio as gr
import modelscope_studio.components.base as ms
import modelscope_studio.components.legacy as legacy
import modelscope_studio.components.antd as antd
import html
import urllib.parse
from huggingface_hub import HfApi, create_repo
import string
import random
import requests # Additional import statement
import os
import sys
import ast # ์ถ”๊ฐ€ ์‚ฝ์ž…
# ํ™˜๊ฒฝ ๋ณ€์ˆ˜์—์„œ ์Šคํฌ๋ฆฝํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ
script_repr = os.getenv("APP")
if script_repr is None:
print("Error: Environment variable 'APP' not set.")
sys.exit(1)
try:
# ๋ฌธ์ž์—ด๋กœ ๋œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ปดํŒŒ์ผํ•˜๊ณ  ์‹คํ–‰
compiled_code = compile(script_repr, '<string>', 'exec')
# ์ „์—ญ ๋ฐ ์ง€์—ญ ๋„ค์ž„์ŠคํŽ˜์ด์Šค ์ •์˜
globals_dict = globals()
locals_dict = {}
# ์ปดํŒŒ์ผ๋œ ์ฝ”๋“œ ์‹คํ–‰
exec(compiled_code, globals_dict, locals_dict)
except Exception as e:
print(f"Error executing script: {e}")
# ์˜ค๋ฅ˜ ์ •๋ณด ๋” ์ž์„ธํžˆ ์ถœ๋ ฅ
import traceback
traceback.print_exc()
sys.exit(1)