diff --git a/.gitignore b/.gitignore index 180de2b..03d536f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ __pycache__/ .py[cod] instance/ +media/ +database.db diff --git a/fhost.py b/fhost.py index 8e5b100..05696ee 100755 --- a/fhost.py +++ b/fhost.py @@ -19,7 +19,7 @@ and limitations under the License. """ -from flask import Flask, abort, make_response, redirect, request, send_from_directory, url_for, Response, render_template +from flask import Flask, abort, make_response, redirect, request, send_from_directory, url_for, render_template from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from jinja2.exceptions import * @@ -35,12 +35,13 @@ from pathlib import Path app = Flask(__name__, instance_relative_config=True) app.config.update( SQLALCHEMY_TRACK_MODIFICATIONS = False, + SQLALCHEMY_DATABASE_URI = "sqlite:///database.db", PREFERRED_URL_SCHEME = "https", # nginx users: make sure to have 'uwsgi_param UWSGI_SCHEME $scheme;' in your config - MAX_CONTENT_LENGTH = 256 * 1024 * 1024, + MAX_CONTENT_LENGTH = 512 * 1024 * 1024, #MiB on top MAX_URL_LENGTH = 4096, USE_X_SENDFILE = False, - FHOST_USE_X_ACCEL_REDIRECT = True, # expect nginx by default - FHOST_STORAGE_PATH = "up", + FHOST_USE_X_ACCEL_REDIRECT = False, # expect nginx by default + FHOST_STORAGE_PATH = "media", FHOST_MAX_EXT_LENGTH = 9, FHOST_EXT_OVERRIDE = { "audio/flac" : ".flac", @@ -55,11 +56,7 @@ app.config.update( "text/plain" : ".txt", "text/x-diff" : ".diff", }, - FHOST_MIME_BLACKLIST = [ - "application/x-dosexec", - "application/java-archive", - "application/java-vm" - ], + FHOST_MIME_BLACKLIST = [], FHOST_UPLOAD_BLACKLIST = None, NSFW_DETECT = False, NSFW_THRESHOLD = 0.608, @@ -346,6 +343,10 @@ def fhost(): else: return render_template("index.html") +@app.route("/web", methods=["GET"]) +def web(): + return render_template("web.html") + @app.route("/robots.txt") def robots(): return """User-agent: * diff --git a/templates/index.html b/templates/index.html index cef9de2..e827bb8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,45 +1,42 @@
-THE NULL POINTER -================ -{% set fhost_url = url_for("fhost", _external=True).rstrip("/") %} -HTTP POST files here: +0w0 +--------------------- {% set fhost_url = url_for("fhost", _external=True).rstrip("/") %} +a selfhosted instance of 0x0 + +try out our new web interface! + +POST API +--------------------- +file upload: curl -F'file=@yourfile.png' {{ fhost_url }} -You can also POST remote URLs: +file upload from remote url: curl -F'url=http://example.com/image.jpg' {{ fhost_url }} -Or you can shorten URLs: +shorten url: curl -F'shorten=http://example.com/some/long/url' {{ fhost_url }} - -File URLs are valid for at least 30 days and up to a year (see below). -Shortened URLs do not expire. {% set max_size = config["MAX_CONTENT_LENGTH"]|filesizeformat(True) %} -Maximum file size: {{ max_size }} -Not allowed: {{ config["FHOST_MIME_BLACKLIST"]|join(", ") }} +max file size: {{ max_size }} +all file types are allowed, but you better not be naughty. -FILE RETENTION PERIOD +TERMS --------------------- +do not use this for: + - piracy + - extremist material of any form + - pornography and gore + - malware or C&C client software + - cryptocurrencies and related information + - *large* backups, ie a hard disk image + - doxxing + - things that are otherwise illegal under US law -retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3) +any uploads with any of these may be removed with no notice. - days - 365 | \\ - | \\ - | \\ - | \\ - | \\ - | \\ - | .. - | \\ - 197.5 | ----------..------------------------------------------- - | .. - | \\ - | .. - | ... - | .. - | ... - | .... - | ...... - 30 | .................... - 0{{ ((config["MAX_CONTENT_LENGTH"]/2)|filesizeformat(True)).split(" ")[0].rjust(27) }}{{ max_size.split(" ")[0].rjust(27) }} - {{ max_size.split(" ")[1].rjust(54) }} +FILE AND URL RETENTION PERIOD +--------------------- +retention = forever. thats right, they are forever. (until someone complains to me) + +THANKS +--------------------- +thanks to mia, for the original 0x0 site.diff --git a/templates/web.html b/templates/web.html new file mode 100644 index 0000000..48e97a7 --- /dev/null +++ b/templates/web.html @@ -0,0 +1,6 @@ +
++