Skip to content

Store, Update and get JSON document using URL.

License

Notifications You must be signed in to change notification settings

pylover/fittonia

Repository files navigation

fittonia

Build Status Coverage Status

Store, Update and get JSON document using URL.

Install

It's highly recommended to use virtualenv to install the fittonia. my favorite virtualenv toolbox is virtualenvwrapper.

So, the workon command on this page is related to the virtualenvwrapper package and you may use your favorite virtualenv utility such as python's builtin.

First install required system packages:

sudo apt install libpq-dev postgresql python3-dev

Then install the fittonia:

git clone https://github.com/pylover/fittonia.git
cd fittonia
pip install [-e] .

Or

pip install git+https://github.com/pylover/fittonia.git

Usage

CLI

Bash Autocompletion
fittonia completion install

Deactivate and activate your virtual environment to use bash auto completion.

deactivate && workon <virtualenv>
Help?

Use the -h/--help to discover all command line features.

fittonia --help
fittonia db --help
fittonia jwt --help
Create database
fittonia db create [-p [postgres-password]]  # default is: postgres

Web API

You can use any wsgi server to serve fittonia, such as gunicorn: create a file named:

wsgi.py

from fittonia import app

Then

gunicorn wsgi:app

Or you may use the serve command to run the python's builtin wsgi server:

fittonia serve [-b 8080]

WebAPI Usage

First, obtain a token via fittonia jwt create <payload> to use web service.

T=$(fittonia jwt create '{"roles": ["admin"], "name": "yourname"}')
echo $T

Then issue a curl to create a json resource for example: `/foo':

curl \
    -H"Authorization: $T" \
    -H"Content-Type: application/json" \
    -X POST \
    -d'{"page": "foo"}' \
    http://localhost:8080/foo
GET

Get the /foo by:

curl localhost:8080/foo

There are some extra verbs to manage the web resources you already saved:

UPDATE
curl \
    -H"Authorization: $T" \
    -H"Content-Type: application/json" \
    -X UPDATE \
    -d'{"page": "foo", "bar": "baz"}' \
    http://localhost:8080/foo
DELETE
curl \
    -H"Authorization: $T" \
    -X DELETE \
    http://localhost:8080/foo

About

Store, Update and get JSON document using URL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published