A Python API For Questionnaire

Overview

Инструкция по разворачиванию приложения

Окружение проекта:

  • python 3.8
  • Django 2.2.10
  • djangorestframework

Склонируйте репозиторий с помощью git:

git clone https://github.com/PontificSalivan/ApiForQuestionnaire

Перейдите в директорию проекта:

cd ./ApiForQuestionnaire

Запустите команду docker:

docker-compose build

или

sudo docker-compose build

Создайте миграции приложения для базы данных:

docker-compose run web python manage.py migrate

или

sudo docker-compose run web python manage.py migrate

Создайте суперпользователя:

docker-compose run web python manage.py createsuperuser

или

sudo docker-compose run web python manage.py createsuperuser

Заполните поля регистрации ( почта необязательна ):

Username (leave blank to use ...): 
Email address: 
Password: 
Password (again): 
Superuser created successfully. 

Запустите приложение (localhost: http://0.0.0.0:8000/):

docker-compose up

или

sudo docker-compose up

Документация API

  • Символ % означает, что нужно вместо него вставить данные

Чтобы получить токен пользователя:

curl --location --request POST 'http://localhost:8000/api/login/' \
--form 'username=%' \
--form 'password=%'

Пример запроса в Postman (form-data)

alt text

Последующие запросы идут с данным выше токеном в Headers как показано ниже:

alt text

Чтобы создать опрос:

  • Request method: POST
  • URL: http://localhost:8000/api/questionnaire/create/
  • Headers:
    • Authorization: Token %
  • Body:
    • questionnaire_name: имя опроса
    • pub_date: дата публикации опроса, формат: YYYY-MM-DD HH:MM:SS
    • end_date: дата конца опроса, формат: YYYY-MM-DD HH:MM:SS
    • questionnaire_description: описание опроса
  • Консольная команда:
curl --location --request POST 'http://localhost:8000/api/questionnaire/create/' \
--header 'Authorization: Token %' \
--form 'questionnaire_name=%' \
--form 'pub_date=%' \
--form 'end_date=%' \
--form 'questionnaire_description=%'

Пример запроса в Postman (form-data)

alt text

Обновить опрос:

  • Request method: PATCH
  • URL: http://localhost:8000/api/questionnaire/update/[questionnaire_id]/
  • Headers:
    • Authorization: Token %
  • Params:
    • questionnaire_id
  • Body:
    • questionnaire_name: имя опроса
    • end_date: дата конца опроса, формат: YYYY-MM-DD HH:MM:SS
    • questionnaire_description: описание опроса
  • Консольная команда:
curl --location --request PATCH 'http://localhost:8000/api/questionnaire/update/[questionnaire_id]/' \
--header 'Authorization: Token %' \
--form 'questionnaire_name=%' \
--form 'end_date=%' \
--form 'questionnaire_description=%'

Пример запроса в Postman (form-data)

alt text

Удалить опрос:

curl --location --request DELETE 'http://localhost:8000/api/questionnaire/update/[questionnaire_id]/' \
--header 'Authorization: Token %'

Пример запроса в Postman (form-data)

alt text

Просмотр всех опросов:

curl --location --request GET 'http://localhost:8000/api/questionnaire/view/' \
--header 'Authorization: Token %'

Пример запроса в Postman (form-data)

alt text

Просмотр текущих активных опросов:

curl --location --request GET 'http://localhost:8000/api/questionnaire/view/active/' \
--header 'Authorization: Token %'

Пример запроса в Postman (form-data)

alt text

Создаем вопрос:

  • Request method: POST
  • URL: http://localhost:8000/api/question/create/
  • Headers:
    • Authorization: Token %
  • Body:
    • questionnaire: id опроса
    • question_text: текст вопроса
    • question_type: может быть только one - вопрос с одиночным ответом, multiple - вопрос с множеством ответов или text - вопрос с текстовым ответом
  • Консольная команда:
curl --location --request POST 'http://localhost:8000/api/question/create/' \
--header 'Authorization: Token %' \
--form 'questionnaire=%' \
--form 'question_text=%' \  
--form 'question_type=%' \

Пример запроса в Postman (form-data)

alt text

Обновляем вопрос:

  • Request method: PATCH
  • URL: http://localhost:8000/api/question/update/[question_id]/
  • Headers:
    • Authorization: Token %
  • Params:
    • question_id
  • Body:
    • questionnaire: id опроса
    • question_text: текст вопроса
    • question_type: может быть только one - вопрос с одиночным ответом, multiple - вопрос с множеством ответов или text - вопрос с текстовым ответом
  • Консольная команда:
curl --location --request PATCH 'http://localhost:8000/api/question/update/[question_id]/' \
--header 'Authorization: Token %' \
--form 'questionnaire=%' \
--form 'question_text=%' \
--form 'question_type=%' \

Пример запроса в Postman (form-data)

alt text

Удаляем вопрос:

curl --location --request DELETE 'http://localhost:8000/api/question/update/[question_id]/' \
--header 'Authorization: Token %' \
--form 'questionnaire=%' \
--form 'question_text=%' \
--form 'question_type=%' \

Пример запроса в Postman (form-data)

alt text

Создаем выбор:

  • Request method: POST
  • URL: http://localhost:8000/api/choice/create/
  • Headers:
    • Authorization: Token %
  • Body:
    • question: id вопроса
    • choice_text: текст выбора
  • Консольная команда:
curl --location --request POST 'http://localhost:8000/api/choice/create/' \
--header 'Authorization: Token %' \
--form 'question=%' \
--form 'choice_text=%'

Пример запроса в Postman (form-data)

alt text

Обновляем выбор:

curl --location --request PATCH 'http://localhost:8000/api/choice/update/[choice_id]/' \
--header 'Authorization: Token %' \
--form 'question=%' \
--form 'choice_text=%'

Пример запроса в Postman (form-data)

alt text

Обновляем выбор:

curl --location --request DELETE 'http://localhost:8000/api/choice/update/[choice_id]/' \
--header 'Authorization: Token %' \
--form 'question=%' \
--form 'choice_text=%'

Пример запроса в Postman (form-data)

alt text

Создаем ответ:

  • Request method: POST
  • URL: http://localhost:8000/api/answer/create/
  • Headers:
    • Authorization: Token %
  • Body:
    • questionnaire: id опроса
    • question: id вопроса
    • choice: если тип вопроса one или multiple, то в данное поле нужен id выбора, иначе вставьте null
    • choice_text: если тип вопроса text, то в данное поле нужен текстовый ответ, иначе вставьте null
  • Консольная команда:
curl --location --request POST 'http://localhost:8000/api/answer/create/' \
--header 'Authorization: Token %' \
--form 'questionnaire=%' \
--form 'question=%' \
--form 'choice=%' \
--form 'choice_text=%'

Пример запроса в Postman (form-data)

alt text

Обновляем ответ:

  • Request method: PATCH
  • URL: http://localhost:8000/api/answer/update/[answer_id]/
  • Headers:
    • Authorization: Token %
  • Params:
    • answer_id
  • Body:
    • questionnaire: id опроса
    • question: id вопроса
    • user_id: id текущего пользователя (если забылся, в предыдущем запросе создания ответа он выводился)
    • choice: если тип вопроса one или multiple, то в данное поле нужен id выбора, иначе вставьте null
    • choice_text: если тип вопроса text, то в данное поле нужен текстовый ответ, иначе вставьте null
  • Консольная команда:
curl --location --request PATCH 'http://localhost:8000/api/answer/update/[answer_id]' \
--header 'Authorization: Token %' \
--form 'questionnaire=%' \
--form 'question=%' \
--form 'choice=%' \
--form 'choice_text=%'

Пример запроса в Postman (form-data)

alt text

Удаляем ответ:

curl --location --request DELETE 'http://localhost:8000/api/answer/update/[answer_id]' \
--header 'Authorization: Token %'

Пример запроса в Postman (form-data)

alt text

Просматриваем ответы пользователя:

curl --location --request GET 'http://localhost:8000/api/answer/view/[user_id]' \
--header 'Authorization: Token %'

Пример запроса в Postman (form-data)

alt text

Framework for Telegram users and chats investigating.

telegram_scan Fantastic and full featured framework for Telegram users and chats investigating. Prerequisites: pip3 install pyrogram; get api_id and a

71 Dec 17, 2022
Discondelete, is a Discord self-bot to delete dm's or purge all messages from a guild.

Discondelete Discondelete, is a Discord self-bot to delete dm's or purge all messages from a guild. Report Bug · Request Feature Table of Contents Abo

core 4 Feb 28, 2022
A Python library for miHoYo bbs and HoYoLAB Community

A Python library for miHoYo bbs and HoYoLAB Community. genshin 原神签到小助手

384 Jan 05, 2023
Cool Discord bot for you

BountyBot Баунти – современный бот созданный с целью сделать ваш сервер лучше! В кратце В нем присутствует множество основных и интересных функций, та

Leestarb Original 1 Nov 22, 2021
Python functions for opentargets.org API

What is opy_Targets? Opentargets.org uses GraphQL API to explore it's content via coding. This ensemble of functions aim is to make it easy to use the

1 Jan 10, 2022
Discord Remote Administration Tool fully written in Python3.

DiscordRAT Discord Remote Administration Tool fully written in Python3. This is a RAT controlled over Discord with over 50 post exploitation modules.

hozzywozzy 2 Feb 06, 2022
Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy

Buy early bsc gems with custom gas fee, slippage, amount. Auto approve token after buy. Sell buyed token with custom gas fee, slippage, amount. And more.

Jesus Crypto 206 May 01, 2022
🖥️ Windows Batch and powershell Discord Token grabber. Made for Troll (lmao)

Batched-Grabber Windows Batch and powershell Discord Token grabber. Made for Troll ! Setup. 1. pip(3) install numpy colored 2. python(3) Batched.py 3.

Ѵιcнч 41 Nov 01, 2022
Simple Reddit bot that replies to comments containing a certain word.

reddit-replier-bot Small comment reply bot based on PRAW. This script will scan the comments of a subreddit as they come in and look for a trigger wor

Kefendy 0 Jun 04, 2022
“ Hey there 👋 I'm Daisy „ AI based Advanced Group Management Bot Suit For All Your Needs ❤️.. Source Code of @Daisyxbot

Project still under heavy development Everything will be changed in the release “ Hey there 👋 I'm Daisy „ AI based Advanced telegram Group Management

TeamDaisyX 43 Nov 12, 2022
A python based all-in-one tool for Google Drive

gdrive-tools A python based all-in-one tool for Google Drive Uses For Gdrive-Tools ✓ generate SA ✓ Add the SA and Add them to TD automatically ✓ Gener

XcodersHub 32 Feb 09, 2022
Aqui está disponível GRATUITAMENTE, um bot de discord feito em python, saiba que, terá que criar seu bot como aplicação, e utilizar seu próprio token, e lembrando, é um bot básico, não se utiliza Cogs nem slash commands nele!

BotDiscordPython Aqui está disponível GRATUITAMENTE, um bot de discord feito em python, saiba que, terá que criar seu bot como aplicação, e utilizar s

Matheus Muguet 4 Feb 05, 2022
ShoukoKomiRobot - An anime themed telegram bot that can convert telegram media

ShoukoKomiRobot • 𝕎𝕣𝕚𝕥𝕥𝕖𝕟 𝕀𝕟 Python3 • 𝕃𝕚𝕓𝕣𝕒𝕣𝕪 𝕌𝕤𝕖𝕕 Pyrogram

25 Aug 14, 2022
Python Client Library to interface with the Phoenix Realtime Server

supabase-realtime-client Python Client Library to interface with the Phoenix Realtime Server This is a fork of the supabase community realtime client

Anand 2 May 24, 2022
Script for polybar to display and control media(not only Spotify) using DBus.

polybar-now-playing Script for polybar to display and control media(not only Spotify) using DBus Python script to display and control current playing

Dope Wizard 48 Dec 31, 2022
Example of a discord bot in Python

discordbot.py Example of a discord bot in Python Requirements Python 3.8 or higher Discord Bot Setting Up Clone this repo or download the files Rename

Debert Jamie 1 Oct 23, 2021
GroupMenter : New Telegram Group Manager Bot🔸Fast 🔸Python🔸Pyrogram 🔸

GroupMenter An PowerFull Group Manager Bot. Written In Pytelethon. Info • A modular Telegram Python bot running on python3. • Can be found on telegram

Group Menter 24 Jun 28, 2022
Telegram Voice Chat Music Player UserBot Written with Pyrogram Smart Plugin and tgcalls

Telegram Voice Chat UserBot A Telegram UserBot to Play Audio in Voice Chats. This is also the source code of the userbot which is being used for playi

Dash Eclipse 7 May 21, 2022
SMAM2 is a package manager built specifically for SourceMod.

SourceMod Addon Manager 2 (SMAM2) SMAM2 is a package manager built specifically for SourceMod. This was heavily inspired by Phil25's SMAM. I thought t

John Mascagni 6 Sep 16, 2022
Weather App using openweathermap API

This is my hobby project used to learn how to use public api for project.In this i used the api of openweathermap to featch the weather details of various city across the globe by giving city name as

Subramanya K S 1 Nov 06, 2021