From 82742d5d13dc7b0691a79c79f8e62782fcb16e10 Mon Sep 17 00:00:00 2001 From: justanothercatgirl Date: Thu, 27 Mar 2025 12:52:11 +0300 Subject: Doing SQL (work in progress) --- www/docs.html | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ www/form.html | 21 +++++++++++ www/index.html | 32 ++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 www/docs.html create mode 100644 www/form.html create mode 100644 www/index.html (limited to 'www') diff --git a/www/docs.html b/www/docs.html new file mode 100644 index 0000000..a2fa287 --- /dev/null +++ b/www/docs.html @@ -0,0 +1,116 @@ + + + + + JAC's link shortener + + +

What is this?

+

This is a link shortener. A sort of a backend practice, but it should run 24/7/53/<While I pay for my VPS> after I finish writing it.

+

Documentation conventions

+

All documentation assumes that the server is running server.com on port 80 without https, and you are trying to shorten a link to example.com.

+

All (non-global) parameters are mandatory, unless marked with question mark ? sign.

+

PATH means part in url after the first slash: e.g. in link http://server.com/short, "short" is PATH, while URL means full shortened link.

+

API reference

+

The API follows this convention: everything is done through GET requests, client supplies all necessary parameters in URLencoded format. + Whatever server returns depends on parameters; it may be application/json (for programmable API) OR text/html (to render in HTML)

+

Example request: http://ln.twistea.su/api/linkadd?url=https%3A%2F%2Fexample.com&format=html.
+ This request may return something like: <a href="http://server.com/DEADF00D">your link: DEADF00D</a>

+

Note: server may return json string like null or true: according to + rfc-8259, this is valid json and clients have to handle this accordingly.

+

Errors are returned like this: {"error": description} (some endpoints may return null / false to indicate failure). + Description may be any of the following:

Plese note that the HTTP return status for malformed request may be BAD_REQUEST (400) or INTERNAL_SERVER_ERROR (500)

+ + + + + + + + + + + + + + + + + + + +
Table 1. Global parameters (applicable to all endpoints)
KeyValueDescriptionDefault
formatjson | htmlHow to return the result of request. html should only be used to embed it in a web page.json
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 2. Endpoints description
EndpointParametersResponse object
keyvalue
/api/linkaddurlstring: a link to be shortened{"url": "https://server.com/PATH"} | error +
try?string: PATH to try to put link under
+ (if not occupied, WITHOUT https://server.com/)
/api/linkdelpathstring: PATH to delete the link fromtrue | false
/api/linkgetpathstring: PATH to get link info from{"url": "original url", created: int unix_timestamp}
+ OR null +
/PATHReturns an HTML page with redirection message and returns 302 (HTTP_FOUND), with + Location header set to shortened URL
/getargsGet an HTML page with a list of all parameters provided to the endpoint. Used for testing.
+

Examples of API usage:

+

This section is unfinished.

+ + diff --git a/www/form.html b/www/form.html new file mode 100644 index 0000000..79eb7b1 --- /dev/null +++ b/www/form.html @@ -0,0 +1,21 @@ + + + + + +
+
+ + +
+
+ + +
+ + +
+ +