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

Unofficial Python wrapper for official Hacker News API

haxor Unofficial Python wrapper for official Hacker News API. Installation pip install haxor Usage Import and initialization: from hackernews import H

147 Sep 18, 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
Total servers you're in!

Discord-Servercount With this script you can check the amount of servers you are in, along with statistics of how many servers you are owner in and in

Nickyux 1 Feb 12, 2022
Catware - A powerful grabber with a built in bot control system

catware A powerful grabber with a built in bot control system PLEASE NOTE THAT I

4 Feb 04, 2022
Stop writing scripts to interact with your APIs. Call them as CLIs instead.

Zum Stop writing scripts to interact with your APIs. Call them as CLIs instead. Zum (German word roughly meaning "to the" or "to" depending on the con

Daniel Leal 84 Nov 17, 2022
scrape tiktok/douyin video list from specific user or keyword

get-tiktok-user-video-list scrape tiktok/douyin video list from specific user or keyword 以**https://www.douyin.com/user/MS4wLjABAAAAUpIowEL3ygUAahQB47

wanghaisheng 4 Jul 06, 2022
A python library for anti-captcha.com

AntiCaptcha A python library for anti-captcha.com Documentation for the API Requirements git Install git clone https://github.com/ShayBox/AntiCaptcha.

Shayne Hartford 3 Dec 16, 2022
A wrapper for aqquiring Choice Coin directly through a Python Terminal. Leverages the TinyMan Python-SDK.

CHOICE_TinyMan_Wrapper A wrapper that allows users to acquire Choice Coin directly through their Terminal using ALGO and various Algorand Standard Ass

Choice Coin 16 Sep 24, 2022
Quickly visualize docker networks with graphviz.

Docker Network Graph Visualize the relationship between Docker networks and containers as a neat graphviz graph. Example Usage usage: docker-net-graph

Leo Verto 43 Dec 12, 2022
troposphere - Python library to create AWS CloudFormation descriptions

troposphere - Python library to create AWS CloudFormation descriptions

4.8k Jan 06, 2023
Webb-Tracker-Bot - This is a discord bot that displays current progress of the James Webb Space Telescope.

Webb-Tracker-Bot - This is a discord bot that displays current progress of the James Webb Space Telescope.

Copperbotte 1 Jan 05, 2022
Automatic SystemVerilog linting in github actions with the help of Verible

Verible Lint Action Usage See action.yml This is a GitHub Action used to lint Verilog and SystemVerilog source files and comment erroneous lines of co

CHIPS Alliance 10 Dec 26, 2022
Balsam Python client API & SDK

balsam No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) This Python package is automatically

Darren Govoni 1 Oct 22, 2021
A youtube videos or channels tag finder python module

A youtube videos or channels tag finder python module

Fayas Noushad 4 Dec 03, 2021
Manage gmail account using python, forget about imap and just code what you supposed to do.

GGmail Manage gmail account using python, forget about imap and just code what you supposed to do. Help See documentation for more details. Install In

Dylan Do Amaral 6 Sep 23, 2022
Python Client for MLflow Tracking Server

Python Client for MLflow Python client for MLflow REST API. Features: Unlike MLflow Tracking client all REST API methods are exposed to user. All clas

MTS 35 Dec 23, 2022
CSUL Discord Bot

Cruzeiro This is the same old bot running on the Discord Server of CSUL, but i've changed the code. It's better now. Discord.py Heroku How i did The b

Operaho 6 Jan 31, 2022
This repository contains the best Data Science free hand-picked resources to equip you with all the industry-driven skills and interview preparation kit.

Best Data Science Resources Hey, Data Enthusiasts out there! Finally, after lots of requests from the community I finally came up with the best free D

Mohit Kumar 415 Dec 31, 2022
Bot per controllare la disponibilità di appuntamenti per la vaccinazione Covid-19 in Veneto

VaxBot9000 Prerequisites Python 3.9 Poetry latest version of geckodriver Firefox Setup poetry install Copy config.sample.toml to config.toml and edit

Augusto Zanellato 5 Jun 13, 2021
Discord Bot written in Python that plays music in your voice channel

Discord Bot that plays music! I decided to create a simple Discord bot using Python in order to advance my coding skills. Please don't ask me for help

Eric Yeung 39 Jan 01, 2023