Git Product home page Git Product logo

questionnaire-api's Introduction

Open Issues Forks Stars Build Maintained Made with Python Open Source Love Built with Love PyBites/Opentrivia

THIS PROJECT IS UNDER ACTIVE DEVELOPMENT, README MAY CHANGE EVERY ONCE IN A WHILE

Index

About

This will be a free to use, open sourced questions database which has a REST API implemented in Python3 & Flask using PostgresSQL database, also this will be a source for a minimal quizzing website which will also let contributors add new questions in multiple categories and as MCQ or T/F types.

Usage

To use this project.

Installation

Development

If you want just to do a simple test run of the application, you can install and use it with development config.

  • Clone the repository
$ git clone https://github.com/PyBites-Open-Source/questionnaire-api.git
  • Create the virtualenv and activate it
$ cd questionnaire-api
$ python -m venv virtualenv
$ source virtualenv/bin/activate # unix
$ .\virtualenv\Scripts\activate  # windows
  • Install requirements
$ pip3 install -r ./src/requirements.txt
  • Create database and apply migrations
$ cd src && flask db upgrade
  • Run the application
$ cd src && flask run

Production

In order to use postgresql database ready for production, you need to use docker and to add some additional environment variables.

  • Setup database
# create .env file wihtin src folder with the following environment variables. 
POSTGRES_USER="trivia"
POSTGRES_PASSWORD="trivia"
POSTGRES_DB_PROD="opentrivia_prod"
POSTGRES_DB_TEST="opentrivia_test"
DB_PORT="5432"
DB_HOST="localhost"

# if you want to change these settings you have to change also the init.sql file 
# from db folder. 
  • Run the application
$ cd src && docker-compose up

File Structure

  • Add a file structure here with the basic details about files, below is an example.
.
โ”œโ”€โ”€ docker
โ”‚ย ย  โ”œโ”€โ”€ api-server
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Dockerfile
โ”‚ย ย  โ””โ”€โ”€ db-server
โ”‚ย ย      โ””โ”€โ”€ Dockerfile
โ”œโ”€โ”€ logo
โ”‚ย ย  โ””โ”€โ”€ opentrivia.png
โ”œโ”€โ”€ src
โ”‚ย ย  โ”œโ”€โ”€ app
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ api
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ routes
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ answers.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ categories.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ questions.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ tests
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_answers.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ test_categories.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ test_questions.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ models
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ answer.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ category.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ question.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ static
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ swagger.json
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ templates
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ base.html
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ developer.html
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ home.html
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ views.py
โ”‚ย ย  โ”œโ”€โ”€ db
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ init.sql
โ”‚ย ย  โ”œโ”€โ”€ instance
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ dev_opentrivia.db
โ”‚ย ย  โ”œโ”€โ”€ migrations
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ versions
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ 798672a50ee1_.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ README
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ alembic.ini
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ env.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ script.py.mako
โ”‚ย ย  โ”œโ”€โ”€ tests
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ test_opentrivia.py
โ”‚ย ย  โ”œโ”€โ”€ config.py
โ”‚ย ย  โ”œโ”€โ”€ docker-compose.yml
โ”‚ย ย  โ”œโ”€โ”€ requirements.txt
โ”‚ย ย  โ””โ”€โ”€ run.py
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ _config.yml

Guideline

  • Code Style

In order to maintain the code style consistency across entire project we use a code formatter. Therefore, we kindly suggest you to do the same whenever you push commits to this project.

The python code formatter we chose is called black. Black is a great tool and it can be installed quickly by running

pip install black.

or

python3.6 -m pip install black

It requires Python 3.6.0+ to run.

  • Usage

black {source_file_or_directory}

For more details and available options, please check the GitHub project.

  • Close Issues

Close issues using keywords: how to ?

Gallery

Endpoints

Available Views

Available Endpoints

  • Questions
    • GET api/v1/questions (Get all Questions)
    • GET api/v1/questions/<id> (Get Question)
    • POST api/v1/questions (Create new Question)
    • PUT api/v1/questions/<id> (Update Question)
    • DELETE api/v1/questions/<id> (Delete Question)
  • Answers
    • GET api/v1/answers/<id> (Get Answer)
    • POST api/v1/answers (Create new Answer)
    • PUT api/v1/answers/<id> (Update Answer)
    • DELETE api/v1/answers/<id (Delete Answer)
  • Categories
    • GET api/v1/categories (Get all Categories)
    • GET api/v1/categories/<id> (Get Category)
    • POST api/v1/categories (Create new Category)
    • PUT GET api/v1/categories/<id> (Update Category)
    • DELETE GET api/v1/categories/<id> (Delete Category)

feel free to add more functionalities endpoint url structure: /api/v1/. . .

Credit/Acknowledgment

Contributors

License

License

questionnaire-api's People

Contributors

bymayanksingh avatar madalinpopa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

questionnaire-api's Issues

API Design

This issue will only be used for project discussions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.