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.
This commit is contained in:
parent
f74aedc547
commit
154df1af2b
2 changed files with 3 additions and 1 deletions
|
@ -38,6 +38,8 @@ def short(shortLink=""):
|
||||||
elif request.method == "POST": # Someone submitted a new link to short
|
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
|
longUrl = request.form["url"] # required, accept the exception if the key does not exist
|
||||||
wishId = request.form.get("wishId")
|
wishId = request.form.get("wishId")
|
||||||
|
if len(longUrl) <= 0:
|
||||||
|
abort(400)
|
||||||
databaseId = insertIdUnique(longUrl, idToCheck=wishId)
|
databaseId = insertIdUnique(longUrl, idToCheck=wishId)
|
||||||
return request.url_root + databaseId # Short link in plain text
|
return request.url_root + databaseId # Short link in plain text
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</div>
|
</div>
|
||||||
<form action="/" method="post" id="short_form">
|
<form action="/" method="post" id="short_form">
|
||||||
<span id="url_text">URL:</span>
|
<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="hidden" name="wishId" value="{{name}}">
|
||||||
<input type="submit" value="Schort!" id="short_button">
|
<input type="submit" value="Schort!" id="short_button">
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue