Store, Update and get JSON document using URL.
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
fittonia completion install
Deactivate and activate your virtual environment to use bash auto completion.
deactivate && workon <virtualenv>
Use the -h/--help
to discover all command line features.
fittonia --help
fittonia db --help
fittonia jwt --help
fittonia db create [-p [postgres-password]] # default is: postgres
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]
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 the /foo
by:
curl localhost:8080/foo
There are some extra verbs to manage the web resources you already saved:
curl \
-H"Authorization: $T" \
-H"Content-Type: application/json" \
-X UPDATE \
-d'{"page": "foo", "bar": "baz"}' \
http://localhost:8080/foo
curl \
-H"Authorization: $T" \
-X DELETE \
http://localhost:8080/foo