Developed with flasks to facilitate and speed up the development of link shortener applications.
- Python 3 or higher
- PIP 3 or higher
- Several python libraries, will be explained later in the installation section
$ git clone https://github.com/dhanuprys/straight-it
$ cd straight-it
$ pip3 install -r requirements.txt
Wait a few moments for it to finish
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
$ STRAIGHT_API_KEY=<yourprivatekey> ...
$ STRAIGHT_HTTP_REFERRER=<drivertype> ...
- 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=<portvalue> ...
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>
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
}
On development
HTTP GET /api/v1/links?key=<yourapikey>
HTTP GET /api/v1/links?key=<yourapikey>&gateway=<yourgateway>
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
HTTP DELETE /api/v1/links?key=<yourapikey>
{
"gateway": "<your previous gateway>", // required
}