Files
tbcmap/help.md

75 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'''Это копипаста из перплексити, чтобы можно было потестить API без фронтенда. В целом всё работает, и даже очень хорошо работает'''
Установите зависимости:
```bash
pip install -r requirements.txt
```
Запустите бэкенд-сервер:
```bash
python auth.py
```
Сервер запустится на http://localhost:5000.
Тестирование API
Вы можете протестировать API с помощью curl, Postman или прямо из браузера:
Проверка работоспособности:
```bash
curl http://localhost:5000/api/health
```
Регистрация:
```bash
curl -X POST http://localhost:5000/api/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"Test123456","password_confirm":"Test123456"}'
```
Вход:
```bash
curl -X POST http://localhost:5000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"Test123456"}'
```
Примеры ответов API
Успешная регистрация:
```json
{
"success": true,
"message": "Регистрация успешна"
}
```
Ошибка валидации:
```json
{
"success": false,
"message": "Ошибки валидации данных",
"errors": {
"username": "Логин должен содержать минимум 4 символа",
"password": "Пароль должен содержать минимум 8 символов, латинские буквы и цифры"
}
}
```
Успешный вход:
```json
{
"success": true,
"message": "Вход выполнен успешно",
"user": {
"username": "testuser"
}
}
```