lljz66 commited on
Commit
96a28db
Β·
verified Β·
1 Parent(s): 3e93781

assets-only root README

Browse files
Files changed (1) hide show
  1. README.md +23 -40
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: API Py
3
  emoji: 🐍
4
  colorFrom: blue
5
  colorTo: green
@@ -8,17 +8,16 @@ pinned: false
8
  app_port: 7860
9
  ---
10
 
11
- # API Py
12
 
13
- Monolith-modular Python (FastAPI) API on Hugging Face Spaces.
14
- Utility endpoints for scraping, URL mapping, favicons β€” and **asset extraction**.
15
 
16
- ## Endpoints
17
 
18
- ### `POST /assets` β€” extract assets from a URL (new 🎯)
19
 
20
- Give it a URL, get back the page's assets grouped by type:
21
- **image Β· video Β· audio Β· svg_icon Β· font**.
22
 
23
  ```bash
24
  curl -X POST https://lljz66-api.hf.space/assets \
@@ -41,7 +40,7 @@ curl -X POST https://lljz66-api.hf.space/assets \
41
  }
42
  ```
43
 
44
- Optional request fields:
45
 
46
  | field | type | default | meaning |
47
  |-------|------|---------|---------|
@@ -49,46 +48,30 @@ Optional request fields:
49
  | `include_data_uris` | bool | `false` | keep `data:` URIs |
50
  | `groups` | list[string] | all | subset: `image`, `video`, `audio`, `svg_icon`, `font` |
51
 
52
- > Static HTML only β€” JS-rendered assets are not captured.
53
-
54
- ### `POST /scrape`
55
- Scrape a website's clean content via Firecrawl.
56
-
57
- ```bash
58
- curl -X POST https://lljz66-api.hf.space/scrape \
59
- -H 'Content-Type: application/json' \
60
- -d '{"url": "https://example.com"}'
61
- ```
62
-
63
- ### `GET /map`
64
- Discover a website's URLs via sitemap + katana crawler.
65
 
66
- ```bash
67
- curl "https://lljz66-api.hf.space/map?url=https://example.com&limit=100"
68
- ```
69
-
70
- ### `GET /favicon`
71
- Get the favicon URL for a website via Google s2.
72
-
73
- ```bash
74
- curl "https://lljz66-api.hf.space/favicon?url=https://example.com"
75
- ```
76
 
77
- ### `GET /health`
78
- Service status.
79
-
80
- ### `GET /debug/katana`
81
- Diagnose katana crawler flags.
82
 
83
  ## Structure (monolith-modular)
84
 
85
  ```
86
  app/
87
  β”œβ”€β”€ main.py # FastAPI app assembly
88
- β”œβ”€β”€ config.py # settings
89
  β”œβ”€β”€ schemas.py # pydantic request/response models
90
- β”œβ”€β”€ routers/ # HTTP layer (health, scrape, map, favicon, assets, debug)
91
- └── services/ # business logic (+ asset extractors/)
 
 
 
 
92
  └── extractors/ # images, videos, audios, icons_svg, fonts
93
  ```
94
 
 
1
  ---
2
+ title: Asset Extractor API
3
  emoji: 🐍
4
  colorFrom: blue
5
  colorTo: green
 
8
  app_port: 7860
9
  ---
10
 
11
+ # Asset Extractor API
12
 
13
+ FastAPI service that extracts assets from any URL, grouped by type:
14
+ **image Β· video Β· audio Β· svg/icon Β· font**.
15
 
16
+ ## Usage
17
 
18
+ ### `POST /assets`
19
 
20
+ Give it a URL, get back the page's assets grouped by category.
 
21
 
22
  ```bash
23
  curl -X POST https://lljz66-api.hf.space/assets \
 
40
  }
41
  ```
42
 
43
+ ### Request fields
44
 
45
  | field | type | default | meaning |
46
  |-------|------|---------|---------|
 
48
  | `include_data_uris` | bool | `false` | keep `data:` URIs |
49
  | `groups` | list[string] | all | subset: `image`, `video`, `audio`, `svg_icon`, `font` |
50
 
51
+ ### Response fields
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
+ | field | type | meaning |
54
+ |-------|------|---------|
55
+ | `url` | string | final URL after redirects |
56
+ | `title` | string \| null | page title |
57
+ | `total` | int | total asset count |
58
+ | `assets` | object | grouped asset URL lists |
 
 
 
 
59
 
60
+ > Static HTML only β€” JS-rendered assets are not captured.
 
 
 
 
61
 
62
  ## Structure (monolith-modular)
63
 
64
  ```
65
  app/
66
  β”œβ”€β”€ main.py # FastAPI app assembly
67
+ β”œβ”€β”€ config.py # settings (fetch limits, SSRF block-list)
68
  β”œβ”€β”€ schemas.py # pydantic request/response models
69
+ β”œβ”€β”€ routers/
70
+ β”‚ └── assets.py # POST /assets (HTTP layer)
71
+ └── services/
72
+ β”œβ”€β”€ fetcher.py # safe async page fetch (SSRF/size/timeout guards)
73
+ β”œβ”€β”€ resolver.py # absolutize asset references
74
+ β”œβ”€β”€ asset_service.py # orchestrator: fetch -> parse -> extract -> group
75
  └── extractors/ # images, videos, audios, icons_svg, fonts
76
  ```
77