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

in-progress decompilation of Gauntlet Legends decompression code on the N64

Gauntlet-Legends A in-progress decompilation of Gauntlet-Legends (N64) decompression code. This project currently supports the US release. Building (L

6 Jul 23, 2022
Linky bot, A open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

LinkyBot Linky bot, An open-source discord bot that allows you to add links to ur website, youtube url, etc for the people all around discord to see!

AlexyDaCoder 1 Sep 20, 2022
A slack bot that notifies you when a restaurant is available for orders

Slack Wolt Notifier A Slack bot that notifies you when a Wolt restaurant or venue is available for orders. How does it work? Slack supports bots that

Gil Matok 8 Oct 24, 2022
100d002 - Simple program to calculate the tip amount and split the bill between all guests

Day 2 - Tip Calculator Simple program to calculate the tip amount and split the

Andre Schickhoff 1 Jan 24, 2022
A command line interface for accessing google drive

Drive Cli Get the ability to access Google Drive without leaving your terminal. Inspiration Google Drive has become a vital part of our day to day lif

Chirag Shetty 538 Dec 12, 2022
FTP Anonymous Login

FTPAnon FTP Anonymous Login Install git clone https://github.com/SiThuTuntimehacker/FTPAnon cd FTPAnon bash install.sh access ftp sever " ftpaccess.tx

SiThuTun 3 Mar 23, 2022
Asynchronous Python Wrapper for the GoFile API

Asynchronous Python Wrapper for the GoFile API

Gautam Kumar 22 Aug 04, 2022
CryptoApp - Python code to pull wallet balances from a variety of different chains through nothing other than your public key.

CryptoApp - Python code to pull wallet balances from a variety of different chains through nothing other than your public key.

Zach Frank 4 Dec 13, 2022
GitPython is a python library used to interact with Git repositories.

Gitoxide: A peek into the future… I started working on GitPython in 2009, back in the days when Python was 'my thing' and I had great plans with it. O

3.8k Jan 03, 2023
A simple program to display current playing from Spotify app on your desktop

WallSpot A simple program to display current playing from Spotify app on your desktop How to Use: Linux: Currently Supports GNOME and KDE. If you want

Nannan 4 Feb 19, 2022
PR Changes Matrix Builder

Pr-changes-matrix-builder - A Github Action that will output a variable to be used in a matrix strategy job based on a PR&'s changes

Kyle James Walker (he/him) 21 Oct 04, 2022
A simple discord tool that translates english to either spanish, german or french and sends it. Free to rework but please give me credit.

discord-translator A simple discord tool that translates english to either spanish, german or french and sends it. Free to rework but please give me c

TrolledTooHard 2 Oct 04, 2021
Herramienta para transferir eventos de Sucuri WAF hacia Azure Data Tables.

Transfiere eventos de Sucuri hacia Azure Data Tables Script para transferir eventos del Sucuri Web Application Firewall (WAF) hacia Azure Data Tables,

CSIRT-RD 1 Dec 22, 2021
Download apps and remove icloud

Download apps and remove icloud

Info & tools for reverse engineering the M6 smart fitness band

m6-reveng This repo contains information and tools for reverse engineering the $7 M6 smart fitness band. Hardware The SoC (system-on-a-chip) is a Teli

41 Dec 26, 2022
Automated endpoint management for Amazon Aurora Global Database

This sample code can be used to manage Aurora global database endpoints. After failover the global database writer endpoints swap from one region to the other. This solution automates creation and ma

AWS Samples 13 Dec 08, 2022
The source code of the bot that displays erotic images on Discord

説明 このコードはDiscord.pyとNeko APIを使ったNsfw画像表示ボットのソースコードです。 成人向けコンテンツを含むボットなので、不快になる方はこのボットの作成中止をおすすめします。 使い方 まず、install.batを起動してください。 そのあとに、config.json を開き

はなくそ 1 Dec 28, 2021
Python wrappers for INHECO ODTC and SCILA libraries by INHECO GmbH.

Python wrappers for INHECO ODTC and SCILA libraries by INHECO GmbH.

1 Feb 09, 2022
Automatically updates the twitter banner with the images of 5 latest followers, using tweepy python

Auto twitter banner Automatically updates the twitter banner every few seconds with follower profile pics on it Here's how it looks! Installation git

Dhravya Shah 7 Jul 04, 2022