mirror of
https://git.0x0.st/mia/0x0.git
synced 2025-04-19 14:53:02 +02:00
fhost: allow configuration at runtime
This reads configuration from a file called `fhost.cfg` if it exists, allowing users to configure the server without having to maintain a fork.
This commit is contained in:
parent
a52127f0c3
commit
51d51d4c00
3 changed files with 10 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
__pycache__/
|
__pycache__/
|
||||||
.py[cod]
|
/fhost.cfg
|
||||||
|
|
|
@ -19,6 +19,13 @@ For all other servers, set ``FHOST_USE_X_ACCEL_REDIRECT`` to ``False`` and
|
||||||
Otherwise, Flask will serve the file with chunked encoding, which sucks and
|
Otherwise, Flask will serve the file with chunked encoding, which sucks and
|
||||||
should be avoided at all costs.
|
should be avoided at all costs.
|
||||||
|
|
||||||
|
You can configure these parameters by creating a file called ``fhost.cfg``
|
||||||
|
and placing normal python assignment statements in it. For example::
|
||||||
|
|
||||||
|
FHOST_USE_ACCEL_REDIRECT = False
|
||||||
|
FHOST_USE_X_SENDFILE = True
|
||||||
|
MAX_URL_LENGTH = 4096
|
||||||
|
|
||||||
To make files expire, simply create a cronjob that runs ``cleanup.py`` every
|
To make files expire, simply create a cronjob that runs ``cleanup.py`` every
|
||||||
now and then.
|
now and then.
|
||||||
|
|
||||||
|
|
2
fhost.py
2
fhost.py
|
@ -68,6 +68,8 @@ app.config["FHOST_UPLOAD_BLACKLIST"] = "tornodes.txt"
|
||||||
app.config["NSFW_DETECT"] = False
|
app.config["NSFW_DETECT"] = False
|
||||||
app.config["NSFW_THRESHOLD"] = 0.608
|
app.config["NSFW_THRESHOLD"] = 0.608
|
||||||
|
|
||||||
|
app.config.from_pyfile("fhost.cfg", silent=True)
|
||||||
|
|
||||||
if app.config["NSFW_DETECT"]:
|
if app.config["NSFW_DETECT"]:
|
||||||
from nsfw_detect import NSFWDetector
|
from nsfw_detect import NSFWDetector
|
||||||
nsfw = NSFWDetector()
|
nsfw = NSFWDetector()
|
||||||
|
|
Loading…
Add table
Reference in a new issue