Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
const marker = '<!-- welcome-bot -->';
const message = `${marker}
👋 # Thanks for your contribution, @${sender}!
👋 Thanks for your contribution, @${sender}!

Please make sure:
- Code is clean and formatted
Expand Down
69 changes: 69 additions & 0 deletions docs/en/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,75 @@ clear # clear screen
exit # exit REPL
```

## Running Application Files

FastHTTP CLI provides two commands to run your application files directly.

### Run Mode — Execute Requests

Run your FastHTTP app in request mode. Executes all registered HTTP requests and displays results:

```bash
fasthttp run main.py
```

With tag filtering:

```bash
fasthttp run main.py --tags api,users
```

Enable debug mode:

```bash
fasthttp run main.py --debug
```

Options:
- `-t, --tags` — Run only routes with specific tags (comma-separated)
- `-d, --debug` — Enable debug mode

### Dev Mode — Development Server

Run your FastHTTP app with an interactive Swagger UI for testing requests:

```bash
fasthttp dev main.py
```

With custom host and port:

```bash
fasthttp dev main.py --host 0.0.0.0 --port 3000
```

With base URL for documentation:

```bash
fasthttp dev main.py --base-url /api
```

Enable debug mode:

```bash
fasthttp dev main.py --debug
```

Options:
- `-h, --host` — Host to bind the server to (default: 127.0.0.1)
- `-p, --port` — Port to bind the server to (default: 8000)
- `-b, --base-url` — Base URL prefix for documentation endpoints
- `-d, --debug` — Enable debug mode

Example output:

```
▲ FastHTTP dev server
➜ Server: http://127.0.0.1:8000
➜ Docs: http://127.0.0.1:8000/docs
─────────────────────────────────
```

## See Also

- [Quick Start](quick-start.md) — basics
Expand Down
181 changes: 110 additions & 71 deletions docs/ru/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,9 @@ fasthttp get https://api.example.com/data --debug
- JSON/data тело
- Заголовки ответа

## Формат вывода

Второй аргумент после URL определяет что вывести:

### status — только статус (по умолчанию)

### Прокси (-p, --proxy)

```bash
fasthttp get https://api.example.com/data status
# 200
# HTTP прокси
fasthttp get https://api.example.com/data -p "http://proxy.example.com:8080"

Expand All @@ -127,131 +119,78 @@ fasthttp get https://api.example.com/data -p "socks5://proxy.example.com:1080"
fasthttp get https://api.example.com/data -p "http://user:password@proxy.example.com:8080"
```

### json — JSON тело ответа

## Формат вывода

Второй аргумент после URL определяет что вывести:

### status — только статус (по умолчанию)

```bash
fasthttp get https://api.example.com/data json
# {"id": 1, "name": "John"}
fasthttp get https://api.example.com/data status
# 200
```

### text — текст ответа

### json — JSON тело ответа

```bash
fasthttp get https://api.example.com/data text
# <html>...</html>
fasthttp get https://api.example.com/data json
# {"id": 1, "name": "John"}
```

### headers — заголовки ответа

### text — текст ответа

```bash
fasthttp get https://api.example.com/data headers
# {"Content-Type": "application/json", "Date": "..."}
fasthttp get https://api.example.com/data text
# <html>...</html>
```

### all — всё вместе

### headers — заголовки ответа

```bash
fasthttp get https://api.example.com/data all
# Status: 200
# Elapsed: 234.56ms
# Headers: {...}
# Body: {...}
fasthttp get https://api.example.com/data headers
# {"Content-Type": "application/json", "Date": "..."}
```

## Примеры

### Простой GET

### all — всё вместе

```bash
$ fasthttp get https://jsonplaceholder.typicode.com/posts/1 json
{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati",
"body": "..."
}
fasthttp get https://api.example.com/data all
# Status: 200
# Elapsed: 234.56ms
# Headers: {...}
# Body: {...}
```

### POST с JSON

## Примеры

### Простой GET

```bash
$ fasthttp post https://jsonplaceholder.typicode.com/posts \
--json '{"title": "foo", "body": "bar", "userId": 1}' json
$ fasthttp get https://jsonplaceholder.typicode.com/posts/1 json
{
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
"id": 1,
"title": "sunt aut facere repellat provident occaecati",
"body": "..."
}
```

### С заголовками

### POST с JSON

```bash
$ fasthttp get https://httpbin.org/headers \
-H "Authorization: Bearer test-token" json
$ fasthttp post https://jsonplaceholder.typicode.com/posts \
--json '{"title": "foo", "body": "bar", "userId": 1}' json
{
"headers": {
"Authorization": "Bearer test-token",
"Host": "httpbin.org"
}
"title": "foo",
"body": "bar",
"userId": 1,
"id": 101
}
```

### С отладкой

### С заголовками

```bash
$ fasthttp get https://httpbin.org/get --debug
ℹ → GET https://httpbin.org/get
✔ HTTP 200 in 234.56ms
ℹ ← Response headers:
ℹ Content-Type: application/json
ℹ Date: Mon, 15 Jan 2025 10:30:00 GMT
$ fasthttp get https://httpbin.org/headers \
-H "Authorization: Bearer test-token" json
{
Expand All @@ -262,14 +201,9 @@ $ fasthttp get https://httpbin.org/headers \
}
```

### Проверить статус API

### С отладкой

```bash
$ fasthttp get https://api.example.com/health
✔ HTTP 200 in 45.23ms
200
$ fasthttp get https://httpbin.org/get --debug
ℹ → GET https://httpbin.org/get
✔ HTTP 200 in 234.56ms
Expand All @@ -278,25 +212,130 @@ $ fasthttp get https://httpbin.org/get --debug
ℹ Date: Mon, 15 Jan 2025 10:30:00 GMT
```

## Справка

### Проверить статус API

```bash
fasthttp --help
fasthttp get --help
fasthttp post --help
$ fasthttp get https://api.example.com/health
✔ HTTP 200 in 45.23ms
200
```

## Интерактивный REPL

Запуск интерактивного режима:

```bash
fasthttp repl
```

С прокси:

```bash
fasthttp repl -p "http://proxy:8080"
```

### Команды REPL

```bash
# Выполнение запросов
get https://api.example.com/data
post https://api.example.com/users -j '{"name": "John"}'
g https://api.example.com/data # сокращение для GET
p https://api.example.com/users # сокращение для POST

# Опции
-H "Key:Value" # заголовки
-j '{"json": 1}' # JSON тело
-d "data" # form данные
-t 30 # таймаут
-o json # формат вывода
-p "proxy" # URL прокси

# Специальные команды
help # показать справку
history # показать историю команд
last # показать последний ответ
clear # очистить экран
exit # выйти из REPL
```

## Запуск файлов приложения

FastHTTP CLI предоставляет две команды для запуска файлов приложения напрямую.

### Режим run — Выполнение запросов

Запустите ваше FastHTTP приложение в режиме выполнения запросов:

```bash
fasthttp run main.py
```

С фильтрацией по тегам:

```bash
fasthttp run main.py --tags api,users
```

Включить режим отладки:

```bash
fasthttp run main.py --debug
```

Опции:
- `-t, --tags` — Запустить только маршруты с определёнными тегами (через запятую)
- `-d, --debug` — Включить режим отладки

### Режим dev — Сервер разработки

Запустите ваше FastHTTP приложение с интерактивным Swagger UI для тестирования запросов:

```bash
fasthttp dev main.py
```

С кастомным хостом и портом:

```bash
fasthttp dev main.py --host 0.0.0.0 --port 3000
```

С базовым URL для документации:

```bash
fasthttp dev main.py --base-url /api
```

Включить режим отладки:

```bash
fasthttp dev main.py --debug
```

Опции:
- `-h, --host` — Хост для сервера (по умолчанию: 127.0.0.1)
- `-p, --port` — Порт для сервера (по умолчанию: 8000)
- `-b, --base-url` — Базовый URL для эндпоинтов документации
- `-d, --debug` — Включить режим отладки

Пример вывода:

```
▲ FastHTTP dev server
➜ Server: http://127.0.0.1:8000
➜ Docs: http://127.0.0.1:8000/docs
─────────────────────────────────
```

## Справка

```bash
fasthttp --help
fasthttp get --help
fasthttp post --help
fasthttp run --help
fasthttp dev --help
```

## Смотрите также
Expand Down
3 changes: 1 addition & 2 deletions examples/basic/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ async def test_delete(resp: Response) -> int:
return resp.status


if __name__ == "__main__":
app.run()

Loading
Loading