File size: 1,995 Bytes
61a815f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | # HTTP API and Web UI Usage
This project includes an HTTP server binary named `api_server`.
It keeps the original `bulk_download` logic unchanged. The server exposes:
- a Web control panel at `/` and `/ui`
- JSON APIs under `/health` and `/jobs`
## Start locally
```bash
cargo build --release --bin bulk_download --bin api_server
./target/release/api_server
```
Default address:
```text
http://localhost:7860
```
Change port:
```bash
API_PORT=8080 ./target/release/api_server
```
If `api_server` cannot find `bulk_download`, set it explicitly:
```bash
BULK_DOWNLOAD_BIN=./target/release/bulk_download \
BULK_DOWNLOAD_WORKDIR=. \
./target/release/api_server
```
## Web UI
Open:
```text
http://localhost:7860/
```
The page lets you:
- submit a trading date in `YYYYMMDD` format
- choose concurrency
- enable or disable forced re-download
- view job status
- inspect final stdout / stderr log tails
## JSON API endpoints
### Health check
```bash
curl http://localhost:7860/health
```
### Create a download job
```bash
curl -X POST http://localhost:7860/jobs \
-H 'Content-Type: application/json' \
-d '{"date":20260224,"concurrent":50,"force":false}'
```
Response example:
```json
{
"job_id": "job-20260425080000-1",
"status": "running",
"status_url": "/jobs/job-20260425080000-1"
}
```
Request fields:
- `date`: trading date in `YYYYMMDD` format.
- `concurrent`: concurrency, default is 50.
- `force`: force re-download, default is false.
### Get one job status
```bash
curl http://localhost:7860/jobs/job-20260425080000-1
```
Statuses:
- `running`
- `succeeded`
- `failed`
The response includes `stdout_tail` and `stderr_tail` for the final logs.
### List all jobs
```bash
curl http://localhost:7860/jobs
```
## Hugging Face Spaces notes
Use a Docker Space and expose port `7860`.
ClickHouse should be external for Hugging Face Spaces. The existing `docker-compose.yml` will not automatically start as a multi-container service inside a Docker Space.
|