|
1 year ago | |
---|---|---|
api | 1 year ago | |
.editorconfig | 1 year ago | |
.gitignore | 1 year ago | |
LICENSE.md | 1 year ago | |
Pipfile | 1 year ago | |
README.md | 1 year ago | |
run.sh | 1 year ago | |
sample.env | 1 year ago | |
server.py | 1 year ago |
This is a small python3 API and website that allows saving bookmarks into an SQLite3 database.
The production environment will eventually be hosted at save.c0de.link
This project uses Pipenv to manage the dependencies, so install that first after cloning this repository.
pipenv install
pipenv shell
bash run.sh
The server will be running on http://localhost:8080/
api_id
and api_hash
api_token
sample.env
to .env
and fill in the details from the previous stepsNow that you have a running server, you can issue requests via a web browser, curl, wget, etc to the following endpoints:
/
- Currently returns the string "This is the index"/save/<title>/<uri>
- Creates a new bookmark entry for the provided uri
. title
is a human readable word/set of words to recognize saved bookmarks quickly. Returns a JSON object containing the uuid
/get/all
or /getall
- Returns a JSON object containing all bookmarks saved, or a 404 error if there are none/get/<uuid>
- Returns a JSON object containing the bookmark. uuid
is a UUID that is returned from /save
, /get/all
and /get/<uuid>
/delete/<uuid>
- Returns a JSON object containing the uuid
and deletion status. Deletes the bookmark. uuid
is a UUID that is returned from /save
, /get/all
and /get/<uuid>
/update/title/<uuid>/<title>
- Changes the bookmark's title
with the newly provided one. Returns the same bookmark object as /get/<uuid>
. uuid
is a UUID that is returned from /save
, /get/all
and /get/<uuid>
/update/uri/<uuid>/<uri>
- Changes the bookmark's uri
with the newly provided one. Returns the same bookmark object as /get/<uuid>
. uuid
is a UUID that is returned from /save
, /get/all
and /get/<uuid>
. By design, the bookmark's uuid
will be updated. If the updated uuid
is already in the database, an HTTP 409 Conflict will be raised.The following fields will be returned with /get
and /update
requests:
uuid
- Required (generated automatically) - This is used for /get
, /update
and /delete
requests
Generate a UUID based on the SHA-1 hash of the python URL namespace identifier
(which is 6ba7b811-9dad-11d1-80b4-00c04fd430c8) and a uri (which is a string)
uri
- Required (user provided) - This is a full link. Currently the API does not verify that it is reachable, so it can be any form of URI, including UNC Paths, or even a bare stringtitle
- Required (user provided) - A human readable word/set of words to recognize saved bookmarks quicklydate_created
- Required (generated automatically) - This is the date and time of the server when the request was received to save a bookmarkdate_updated
- Optional (generated automatically) - This is the date and time of the server when the request was received to update a bookmark