Skip to content

dhanuprys/straight-it

Repository files navigation

Straight.it

logo Developed with flasks to facilitate and speed up the development of link shortener applications.

Requirements 📄

  • Python 3 or higher
  • PIP 3 or higher
  • Several python libraries, will be explained later in the installation section

Step by Step to Install 🚶

Download from Github ⤵️

$ git clone https://github.com/dhanuprys/straight-it
$ cd straight-it

Install the Required Dependencies 🏗️

$ pip3 install -r requirements.txt

Wait a few moments for it to finish

Run the Application 🚀

Before running the application, you must pay attention to the following things such as port settings, access keys and others.

All these configurations can be configured through the environment.

Simply the application can be run with the following command:

$ STRAIGHT_API_KEY=yourprivatekey python3 __main__.py

API Key Settings (required) 🔑

$ STRAIGHT_API_KEY=<yourprivatekey> ...

HTTP Redirect Settings ➡️

$ STRAIGHT_HTTP_REFERRER=<drivertype> ...

HTTP driver type list:

  • http (default)
  • javascript / js

If you choose http, the server will provide a response in the form of a status code which will redirect to the intended link. But if you use javascript / js then the server will display an html page containing javascript code which will redirect to the destination page

Port Settings (default: 8080) 🚪

$ PORT=<portvalue> ...

API Access Guide 🔗

Straight.it implements the CRUD api model. So everything is easier now if you want to save, modify, delete, or even view the entire list of data that has been saved.

All matters concerning API access must use the following url.

http://yourhosturl.com/api/v1/links

All access to the API requires the api key that you have set yourself in the STRAIGHT_API_KEY environment and will be passed at the end of the url as a 'key' parameter as shown below.

http://yourhosturl.com/api/v1/links?key=<yourapikey>

Store Data (create) ➕

HTTP POST /api/v1/links?key=<yourapikey>
{
  "gateway": "<your gateway>", // if this field is not declared then the server will perform a random gateway selection
  "target": "<your target url, example: http://github.com/dhanuprys>" // required
}

Get All the Data (read all) 👁️

On development

HTTP GET /api/v1/links?key=<yourapikey>

Get Specific Data (read spesific) 👓

HTTP GET /api/v1/links?key=<yourapikey>&gateway=<yourgateway>

Update Existing Data (update) 👓 ➖ ➕

HTTP PUT /api/v1/links?key=<yourapikey>
{
  "gateway": "<your previous gateway>", // required
  "target": "<your new target>" // required
}

You can use PUT or UPDATE as the request method

Delete Existing Data (delete) ➖

HTTP DELETE /api/v1/links?key=<yourapikey>
{
  "gateway": "<your previous gateway>", // required
}

About

Simple link shortener

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published