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

Add WSGI components and README

parent c570200b
# liteshort
liteshort is a simple, configurable link shortener.
![liteshort screenshot](
README coming soon.
# 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
# Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use to generate
# String: Hashed password (bcrypt) to make admin API requests - Preferred over plaintext, use 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'
# 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'
# 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
module = wsgi:app
master = true
processes = 2
socket = liteshort.sock
chmod-socket = 660
vacuum = true
die-on-term = true
......@@ -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']):
Description=uWSGI instance to serve liteshort
ExecStart=/path/to/install/virtualenv/bin/uwsgi --ini liteshort.ini
......@@ -9,6 +9,7 @@ A copy of the MIT license can be obtained at
<meta charset="UTF-8">
<title>{{ config.site_name }}</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="">
<link href="" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
from liteshort import app
if __name__ == "__main__":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment