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

A python to scratch API connector. Can fetch data from the API and send it back in cloud variables.

Scratch2py Scratch2py or S2py is a easy to use, versatile tool to communicate with the Scratch API Based of scratchclient by Raihan142857 Installation

20 Jun 18, 2022
1.本项目采用Python Flask框架开发提供(应用管理,实例管理,Ansible管理,LDAP管理等相关功能)

op-devops-api 1.本项目采用Python Flask框架开发提供(应用管理,实例管理,Ansible管理,LDAP管理等相关功能) 后端项目配套前端项目为:op-devops-ui jenkinsManager 一.插件python-jenkins bug修复 (1).插件版本 pyt

3 Nov 12, 2021
RichWatch is wrapper around AWS Cloud Watch to display beautiful logs with help of Python library Rich.

RichWatch is TUI (Textual User Interface) for AWS Cloud Watch. It formats and pretty prints Cloud Watch's logs so they are much more readable. Because

21 Jul 25, 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
Bot playing "mathbattle" game from Telegram messenger

mathbattlebot Bot playing mathbattle game from Telegram messenger Installing: run in command line pip3 install -r requirements.txt Running: Example c

Egor 1 May 30, 2022
Discord bot script for sending multiple media files to a discord channel according to discord limitations.

Discord Bulk Image Sending Bot Send bulk images to Discord channel. This is a bot script that will allow you to send multiple images to Discord channe

Nikola Arbov 1 Jan 13, 2022
Unofficial API wrapper for seedr.cc

Seedr API Unofficial API wrapper for seedr.cc Inspired by theabbie's seedr-api Powered by @harp_tech (Telegram) How to use You can install lib via git

Anjana Madu 49 Oct 24, 2022
A Telegram Userbot to play or streaming Audio and Video songs / files in Telegram Voice Chats.

Vcmusic-Userbot A Telegram Userbot to play or streaming Audio and Video songs / files in Telegram Voice Chats. It's made with PyTgCalls and Pyrogram R

3 Oct 23, 2021
Repositorio dedicado a contener los archivos fuentes del bot de discord "Lector de Ejercicios".

Lector de Ejercicios Este bot de discord está pensado para usarse únicamente en el discord de la materia Algoritmos y Programación I, de la Facultad d

Franco Lighterman Reismann 3 Sep 17, 2022
A tool that ensures consistent string quotes in your Python code.

pyquotes Single quotes are superior. And if you disagree, there's an option for this as well. In any case, quotes should be consistent throughout the

Adrian 9 Sep 13, 2022
A Telegram Repo For Devs To Controll The Bots Under Maintenance.This Bot Is For Developers, If Your Bot Is Down, Use This Repo To Give Your Dear Subscribers Some Support By Providing Them Response.

Maintenance Bot A Telegram Repo For Devs To Controll The Bots Under Maintenance About This Bot This Bot Is For Developers, If Your Bot Is Down, Use Th

Vɪᴠᴇᴋ 47 Dec 29, 2022
This project is a basic login system in terminal for Discord

Welcome to Discord Login System(Terminal) 👋 This project is a basic login system in terminal for Discord Author 👤 arukovic Github: @SONIC-CODEZ Show

SONIC-CODEZ 2 Feb 11, 2022
A modular Telegram Python bot running on python3 with a sqlalchemy, redis, telethon.

GilbertAnimeBot A modular Telegram Python bot running on python3 with a sqlalchemy, redis, telethon. How to setup/deploy. Read these notes carefully b

Kishore 1 Jan 23, 2022
JAKYM, Just Another Konsole YouTube-Music. A command line based Youtube music player written in Python with spotify and youtube playlist support

Just Another Konsole YouTube-Music Overview I wanted to create this application so that I could use the command line to play music easily. I often pla

Mayank Jha 73 Jan 01, 2023
radiant discord anti nuke src leaked lol.

radiant-anti-wizz-leaked radiant discord anti nuke src leaked lol, the whole anti sucks but idc. sucks to suck thats tuff bro LMAOOOOOO join my server

ok 15 Aug 06, 2022
Discord bot that plays cricket with the user

CricBot Table of content Commands Installation Game rules License Commands S.No Command Use 1. cric Open the home window. This command is not necessa

Raveesh Yadav 1 Nov 19, 2021
Fetch torrent links from nyaa, according to releases by smoke index.

Nyaa - Smoke's index torrent fetcher Description This script parses the local (or online) anime release index (csv format) made by Big Smoke. And uses

Dinank 21 Jun 08, 2022
A bot that can play songs in Telegram group voice chats like AK 47

🎧 47Music Player 🎧 A bot that can play songs in Telegram group voice chats like AK 47 ✨ Easy To Deploy Pyrogram Session Config Vars API_ID : Assista

Janindu Malshan 23 Dec 07, 2022
This is a music bot for discord written in python

this is a music bot for discord written in python, it is designed for educational use ONLY, I do not take any responsibility for uses outside of educational use

5 Dec 24, 2021
Mass Instagram Checker

Mass Instagram Checker

X - MrG3P5 5 Nov 09, 2022