summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-06-26 11:50:10 +0200
committerAnton Khirnov <anton@khirnov.net>2022-06-26 11:51:22 +0200
commitc441e411d0ac68a78554d15e302a74fdeabb7420 (patch)
tree02e70f72e2833659483cd2dabf29e0e2f02accc1
parent3d1d1caa6c7c25f12655e71d7b58d48f9ef6b1ec (diff)
Remove URL shortening functionality.
Gets rid of the validators dependency.
-rwxr-xr-xfhost.py24
-rw-r--r--requirements.txt1
2 files changed, 0 insertions, 25 deletions
diff --git a/fhost.py b/fhost.py
index 293e88e..ea2b8d7 100755
--- a/fhost.py
+++ b/fhost.py
@@ -30,7 +30,6 @@ from mimetypes import guess_extension
import os, sys
import requests
from short_url import UrlEncoder
-from validators import url as url_valid
app = Flask(__name__)
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
@@ -150,24 +149,6 @@ def fhost_url(scheme=None):
def is_fhost_url(url):
return url.startswith(fhost_url()) or url.startswith(fhost_url("https"))
-def shorten(url):
- if len(url) > app.config["MAX_URL_LENGTH"]:
- abort(414)
-
- if not url_valid(url) or is_fhost_url(url) or "\n" in url:
- abort(400)
-
- existing = URL.query.filter_by(url=url).first()
-
- if existing:
- return existing.geturl()
- else:
- u = URL(url)
- db.session.add(u)
- db.session.commit()
-
- return u.geturl()
-
def in_upload_bl(addr):
if os.path.isfile(app.config["FHOST_UPLOAD_BLACKLIST"]):
with open(app.config["FHOST_UPLOAD_BLACKLIST"], "r") as bl:
@@ -346,8 +327,6 @@ def fhost():
return store_file(request.files["file"], request.remote_addr)
elif "url" in request.form:
return store_url(request.form["url"], request.remote_addr)
- elif "shorten" in request.form:
- return shorten(request.form["shorten"])
abort(400)
else:
@@ -371,11 +350,8 @@ HTTP POST files here:
curl -F'file=@yourfile.png' {0}
You can also POST remote URLs:
curl -F'url=http://example.com/image.jpg' {0}
-Or you can shorten URLs:
- curl -F'shorten=http://example.com/some/long/url' {0}
File URLs are valid for at least 30 days and up to a year (see below).
-Shortened URLs do not expire.
Maximum file size: {1}
Not allowed: {5}
diff --git a/requirements.txt b/requirements.txt
index 7168db6..f22a8c5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -10,4 +10,3 @@ flask_migrate
flask_script
python_magic
short_url
-validators