Coder Social home page Coder Social logo

vb's Introduction

Intro

Simple and lightweight application to organize volleyball events.

Sqlite engine is used to manage a database.

vb.cgi is rest-like API in python3.

Dependencies

  • python3
  • sqlite3
  • python
  • web server to handle cgi (e.g. apache2, nginx+fastcgi)

Structure

  • cgi-bin contains database API
  • css, js, *.html are regular html files

Database API

vb.cgi parses form (QUERY_STRING) from a web-server and replies with a json.
Env var VOLLEY_DB overwrites default database.
Env var VOLLEY_DEBUG enables debugging.

API

action=init - Initializes a database with tables.

action=add_event&date=d&location=l3&payment_link=p - Adds an event.

action=events - Returns all events.

action=update_event&id=3&date=d&location=l3&payment_link=p - Updates an event.

action=add_guest&event_id=3&name=n&position=pos - Adds an event. If event_id is not set, a guest is added to a primary event.

action=event&id=3 - Returns an event with all guests. If id is not provided a primary event is used.

action=remove_guest&id=2 - To remove a guest.

action=set_primary_event&id=2 - Set a primary event. A primary event is the one which is displayed at index.html.

action=shame - Returns list of last N cancellations.

In short a reply to every request fits {"message": XXX, "status":0}.
status=0 is on success and message contains corresponding data.
status=1 is on failure and message contains an error message.

Testing

The tests are written using standard unittest package so they can be run with any standard compliant test runner (e.g. pytest, nose, nose2)

Recommended way:

$ pip install pytest
$ pytest

No-dependency version using built-in test runner:

python -m unittest discover -s tests

Bootstrapping

To run it locally from the repo root:

# initialize the database
(cd cgi-bin && ./init.sh)
# start the cgi web server
VOLLEY_DB=cgi-bin/vb.sqlite python3 -m http.server --bind 0.0.0.0 --cgi 8000

And now open localhost:8000 in browser.

TODO

  • Make an event clickable on /events.html.

vb's People

Contributors

sharifmarat avatar

Watchers

 avatar

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.