Commit 9d424a89 authored by 132ikl's avatar 132ikl
Browse files

Add WSGI components and README

parent c570200b
Loading
Loading
Loading
Loading

README.md

0 → 100644
+6 −0
Original line number Diff line number Diff line
# liteshort
liteshort is a simple, configurable link shortener.

![liteshort screenshot](https://fs.ikl.sh/selif/4cgndb6e.png)

README coming soon.
+10 −6
Original line number Diff line number Diff line
# Username to make admin API requests
# String: Username to make admin API requests
# Default: 'admin'
admin_username: 'admin'

# Plaintext password to make admin API requests
# String: Plaintext password to make admin API requests
# Safe to remove if admin_hashed_password is set
# Default: unset
#admin_password:

# Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use securepass.sh to generate
# String: Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use securepass.sh to generate
# Please note that authentication takes noticeably longer than using plaintext password
# Don't include the <username>: segment, just the hash
# Default: unset (required to start application)
admin_hashed_password: '$2y$15$Dhll3IY42R.JNOYazarlG.8IndwMjxmHLpFsebJzcGTJd.gbsAwna'
admin_hashed_password:

# Boolean: Disables API. If set to true, admin_password/admin_hashed_password do not need to be set.
# Default: false
disable_api: false

# String: Secret key used for cookies (used for storage of messages)
# This should be a 12-16 character randomized string with letters, numbers, and symbols
# Default: unset (required to start application)
secret_key: 'S$JI8L*&xua%gBoL'
secret_key:

# String: Filename of the URL database without extension
# Default: 'urls'
@@ -45,4 +49,4 @@ site_url:

# Boolean: Show link to project repository on GitHub at bottom right corner of page
# Default: true
show_github_link: false
 No newline at end of file
show_github_link: true

liteshort.ini

0 → 100644
+12 −0
Original line number Diff line number Diff line
[uwsgi]
module = wsgi:app

master = true
processes = 2

socket = liteshort.sock
chmod-socket = 660
vacuum = true

die-on-term = true
+13 −9
Original line number Diff line number Diff line
@@ -21,12 +21,14 @@ def load_config():
    req_options = {'admin_username': 'admin', 'database_name': "urls", 'random_length': 4,
                   'allowed_chars': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
                   'random_gen_timeout': 5, 'site_name': 'liteshort', 'site_url': None, 'show_github_link': True,
                   'secret_key': None
                   'secret_key': None, 'disable_api': False
                   }

    config_types = {'admin_username': str, 'database_name': str, 'random_length': int,
                    'allowed_chars': str, 'random_gen_timeout': int, 'site_name': str,
                    'site_url': (str, type(None)), 'show_github_link': bool, 'secret_key': str}
                    'site_url': (str, type(None)), 'show_github_link': bool, 'secret_key': str,
                    'disable_api': bool
                    }

    for option in req_options.keys():
        if option not in new_config.keys():  # Make sure everything in req_options is set in config
@@ -42,7 +44,7 @@ def load_config():
                    matches = True
            if not matches:
                raise TypeError(option + " is incorrect type")

    if not new_config['disable_api']:
        if 'admin_hashed_password' in new_config.keys():  # Sets config value to see if bcrypt is required to check password
            new_config['password_hashed'] = True
        elif 'admin_password' in new_config.keys():
@@ -234,6 +236,8 @@ def main_post():
        return response(request, (current_app.config['site_url'] or request.base_url) + short,
                        'Error: Failed to generate')
    elif 'api' in request.form:
        if current_app.config['disable_api']:
            return response(request, None, "API is disabled.")
        # All API calls require authentication
        if not request.authorization \
                or not authenticate(request.authorization['username'], request.authorization['password']):

liteshort.service

0 → 100644
+13 −0
Original line number Diff line number Diff line
[Unit]
Description=uWSGI instance to serve liteshort
After=network.target

[Service]
User=
Group=www-data
WorkingDirectory=/path/to/install
Environment="PATH=/path/to/install/virtualenv/bin"
ExecStart=/path/to/install/virtualenv/bin/uwsgi --ini liteshort.ini

[Install]
WantedBy=multi-user.target
Loading