Browse Source

Fix url input and mark it as required

Validation is done in html on the client
and raises an error 400 in the api.

This fixes #2.
head_fix
sqozz 2 years ago
parent
commit
154df1af2b
2 changed files with 3 additions and 1 deletions
  1. +2
    -0
      schort.py
  2. +1
    -1
      templates/index.html

+ 2
- 0
schort.py View File

@@ -38,6 +38,8 @@ def short(shortLink=""):
elif request.method == "POST": # Someone submitted a new link to short
longUrl = request.form["url"] # required, accept the exception if the key does not exist
wishId = request.form.get("wishId")
if len(longUrl) <= 0:
abort(400)
databaseId = insertIdUnique(longUrl, idToCheck=wishId)
return request.url_root + databaseId # Short link in plain text


+ 1
- 1
templates/index.html View File

@@ -12,7 +12,7 @@
</div>
<form action="/" method="post" id="short_form">
<span id="url_text">URL:</span>
<input type="input" name="url" id="url_input">
<input type="url" name="url" id="url_input" required>
<input type="hidden" name="wishId" value="{{name}}">
<input type="submit" value="Schort!" id="short_button">
</form>

Loading…
Cancel
Save