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

Discord bot template.py

discord_bot_template.py A minimal and open-source discord.py boilerplate for kick-starting bot projects. I spend a lot of time developing bots for dif

Tarran Prior 1 Feb 24, 2022
A Simple modular tool to fetch and parse data related to the stock market.

🐒 stonks-o-fetcher A Simple modular tool to fetch and parse data related to the stock market. Getting started For the moment the only source is this

Daniele 23 May 31, 2021
pokemon-colorscripts compatible for mac

Pokemon colorscripts some scripts to print out images of pokemons to terminal. Inspired by DT's colorscripts compilation Description Prints out colore

43 Jan 06, 2023
A basic Ubisoft API wrapper created in python.

UbisoftAPI A basic Ubisoft API wrapper created in python. I will be updating this with more endpoints as time goes on. Please note that this is my fir

Ethan 2 Oct 31, 2021
A script that takes what you're listening too on Spotify and sets it as your Nertivia custom status.

nertivia-spotify-listening-status A script that takes what you're listening too on Spotify and sets it as your Nertivia custom status. setup Install r

Ben Tettmar 2 Feb 03, 2022
Offline reverse geocoder in Python using sqlite3

rgeocode Offline reverse geocoder rgeocode accepts a geographic coordinate pair (latitude and longitude) and returns a list containing the name of: A

Venkat 7 Dec 01, 2021
It is automated instagram follower bot.

Instagram-Follower-Bot It is automated instagram follower bot. In This project I've used Selenium and Python. Work-Flow When I run my code. It's gonna

Falak Shair 3 Sep 28, 2022
My telegram bot to download Instagram Profiles

Instagram Profile Get for Telegram My telegram bot to download Instagram Profiles First you have to get a telegrm bot api key from @BotFather Then you

Ali Yoonesi 2 Sep 22, 2022
Wrapper around the UPS API for creating shipping labels and fetching a package's tracking status.

ClassicUPS: A Useful UPS Library ClassicUPS is an Apache2 Licensed wrapper around the UPS API for creating shipping labels and fetching a package's tr

Jay Goel 55 Dec 12, 2022
Discord Bot Personnal Server - Ha-Neul

Haneul Bot, it's a discord for help me on my personnal discord, she do a lot of boring and repetitive stain. You can use on your own server if you want, you just need to find a host for the programm

Maxvyr 1 Feb 03, 2022
Google Drive, OneDrive and Youtube as covert-channels - Control systems remotely by uploading files to Google Drive, OneDrive, Youtube or Telegram

covert-control Control systems remotely by uploading files to Google Drive, OneDrive, Youtube or Telegram using Python to create the files and the lis

Ricardo Ruiz 52 Dec 06, 2022
Shows VRML team stats of all players in your pubs

VRML Team Stat Searcher Displays Team Name, Team Rank (Worldwide), and tier of all the players in your pubs. GUI WIP: Username search works & pub name

Hamish 2 Dec 22, 2022
KaydyPurge - Python Purge Script for Discord made by Kaydy Cain#0001

How to Install Open terminal Execute "git clone https://github.com/apolo1337/Kay

apolo 5 Jan 27, 2022
Cdk-python-crud-app - CDK Python CRUD App

Welcome to your CDK Python project! You should explore the contents of this proj

Shapon Sheikh 1 Jan 12, 2022
A simple, lightweight Discord bot running with only 512 MB memory on Heroku

Haruka This used to be a music bot, but people keep using it for NSFW content. Can't everyone be less horny? Bot commands See the built-in help comman

Haruka 4 Dec 26, 2022
Isobot is originally made by notsniped. This is a remix of iso.bot by archisha.

iso6.9-1.2beta iso.bot is originally made by notsniped#0002. This is a remix of iso.bot by αrchιshα#5518. iso6.9 is a Discord bot written in Python an

Kamilla Youver 3 Jan 11, 2022
PYAW allows you to call assembly from python

PYAW allows you to call assembly from python

2 Dec 13, 2021
Discord bot do sprawdzania ceny pizzy.

Discord bot do sprawdzania ceny pizzy w pizzeri Bombola. Umieszczony jest na platformie Heroku, dzięki czemu działa 24/7. Commands List Info: Jako com

1 Sep 18, 2021
A simple language translator with python and google translate api

Language translator with python A simple language translator with python and google translate api Install pip and python 3.9. All the required depende

0 Nov 11, 2021
A discord token grabber made in Python 3

Discord Token Grabber A Discord token grabber written in Python 3. This version of the grabber only supports Windows. Features Transfers via Discord w

Mega145 4 Aug 04, 2022