Giter Site home page Giter Site logo

api_final_yatube's Introduction

ЯП - Спринт 9 - Проект «API для Yatube». Python-разработчик (бэкенд)

API для Yatube представляет собой проект социальной сети в которой реализованы возможности:

  • публиковать записи
  • комментировать записи
  • подписываться или отписываться от авторов.

Технологии:

  • Python 3.7
  • Django 3.2
  • DRF
  • JWT + Djoser

Запуск проекта в dev-режиме:

  • Клонировать репозиторий и перейти в него в командной строке.
  • Установите и активируйте виртуальное окружение c учетом версии Python 3.7 :
  • python -m venv venv
  • source/venv/Scripts/activate

Затем нужно установить все зависимости из файла requirements.txt:

pip install -r requirements.txt Выполняем миграции: python manage.py migrate

Создаем суперпользователя: python manage.py createsuperuser

Запускаем проект: python manage.py runserver

Примеры запросов

Примеры запросов:

Получение токена:

  • Отправить POST-запрос на адрес api/v1/jwt/create/ и передать 2 поля в data:

  • username - имя пользователя.

  • password - пароль пользователя.

Создание поста:

  • Отправить POST-запрос на адрес api/v1/posts/ и передать обязательное поле text, в заголовке указать Authorization:Bearer <токен>.

Пример запроса:

{ "text": "Мой первый пост." } Пример ответа:

{ "id": 2, "author": "Evgeniy", "text": "Мой первый пост.", "pub_date": "2022-12-26T23:11:22.021094Z", "image": null, "group": null }

Комментирование поста пользователя:

  • Отправить POST-запрос на адрес api/v1/posts/{post_id}/comments/ и передать обязательные поля post и text, в заголовке указать Authorization:Bearer <токен>.

Пример запроса:

{ "post": 1, "text": "Тест" } Пример ответа:

{ "id": 1, "author": "Evgeniy", "text": "Тест", "created": "2022-12-26T23:12:13.146875Z", "post": 1 }

Ресурсы:

api_final_yatube's People

Contributors

evgeniy-sp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.