Download config.py from Tianluhua/api-proxy: direct link, hf CLI and curl.
- Browser
- Download file 2.28 kB
-
https://huggingface.co/spaces/Tianluhua/api-proxy/resolve/main/config.py
- Command line
-
hf download hf://spaces/Tianluhua/api-proxy/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Tianluhua/api-proxy/resolve/main/config.py
2.28 kB
| # config.py | |
| # 代理配置模板 - 已配置 momoyu.cc 热榜API | |
| PROXY_CONFIGS = { | |
| # 热榜聚合API (momoyu.cc) | |
| "hotlist": { | |
| "name": "热榜聚合API", | |
| "base_url": "https://momoyu.cc", | |
| "endpoints": { | |
| # 核心接口:获取热门列表 | |
| "/api/hot/list": { | |
| "methods": ["GET"], # 支持的方法 | |
| "params": {"type": 0}, # 默认参数 type=0 | |
| "description": "获取全站热门列表 (type: 0-综合, 1-知乎, 2-微博等)" | |
| }, | |
| # 可以预留其他可能的端点 | |
| "/api/hot/detail": { | |
| "methods": ["GET"], | |
| "params": {}, | |
| "description": "获取热榜详情 (如果源站支持)" | |
| } | |
| }, | |
| # 全局请求头(模拟浏览器访问,降低被拒风险) | |
| "headers": { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", | |
| "Accept": "application/json, text/plain, */*", | |
| "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8", | |
| "Referer": "https://momoyu.cc/" | |
| } | |
| }, | |
| # ==================== 未来添加新接口从这里开始 ==================== | |
| # 示例:添加新的API | |
| # "new_api": { | |
| # "name": "新API名称", | |
| # "base_url": "https://api.example.com", | |
| # "endpoints": { | |
| # "/v1/data": { | |
| # "methods": ["GET", "POST"], | |
| # "params": {"limit": 20}, | |
| # "description": "获取数据" | |
| # } | |
| # }, | |
| # "headers": { | |
| # "Authorization": "Bearer your-token" | |
| # } | |
| # }, | |
| } | |
| # 全局配置 | |
| GLOBAL_CONFIG = { | |
| "timeout": 30, # 请求超时时间(秒) | |
| "enable_cache": False, # 是否启用缓存 | |
| "cache_ttl": 60, # 缓存时长(秒) | |
| "require_auth": False, # 是否需要访问密钥(保持False以便公开使用) | |
| "auth_token": "", # 如果require_auth=True,客户端需携带此token | |
| "log_requests": True, # 是否记录请求日志 | |
| "allowed_origins": ["*"] # CORS允许的域名,*表示允许所有 | |
| } |