Compare commits
1 Commits
d3c744e072
...
c5236c6fc4
Author | SHA1 | Date | |
---|---|---|---|
c5236c6fc4 |
|
@ -6,6 +6,6 @@ Note: I switched to Gunicorn at some point because Bjoern was somehow annoying.
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
|
|
||||||
```passlib argon2_cffi flask gunicorn```
|
```passlib argon2_cffi flask gunicorn flask-paranoid```
|
||||||
|
|
||||||
This application makes use of the `secrets` module (a cryptographically strong version of `random`) from the standard library, which is only available in Python 3.6+. If you really can't be bothered use the latest version of python3, or just don't want cryptographically strong random character filenames/prefixes for some reason, you can directly replace all instances of `secrets` with `random`.
|
This application makes use of the `secrets` module (a cryptographically strong version of `random`) from the standard library, which is only available in Python 3.6+. If you really can't be bothered use the latest version of python3, or just don't want cryptographically strong random character filenames/prefixes for some reason, you can directly replace all instances of `secrets` with `random`.
|
||||||
|
|
10
fileHost.py
10
fileHost.py
|
@ -14,6 +14,7 @@ from passlib.hash import argon2
|
||||||
from flask import Flask, session, request, abort, redirect, url_for, g, \
|
from flask import Flask, session, request, abort, redirect, url_for, g, \
|
||||||
render_template
|
render_template
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
from flask_paranoid import Paranoid
|
||||||
|
|
||||||
class ReverseProxied(object):
|
class ReverseProxied(object):
|
||||||
"""
|
"""
|
||||||
|
@ -74,7 +75,6 @@ app.config["UPLOAD_URL"] = "https://steelbea.me/up/"
|
||||||
app.config["DB_NAME"] = "fileHost.db"
|
app.config["DB_NAME"] = "fileHost.db"
|
||||||
app.config["DB_LOCK"] = threading.Lock()
|
app.config["DB_LOCK"] = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def db_execute(*args, **kwargs):
|
def db_execute(*args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Opens a connection to the app's database and executes the SQL statements
|
Opens a connection to the app's database and executes the SQL statements
|
||||||
|
@ -88,7 +88,6 @@ def db_execute(*args, **kwargs):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""
|
"""
|
||||||
Initializes the application.
|
Initializes the application.
|
||||||
|
@ -114,7 +113,8 @@ def init():
|
||||||
"id INTEGER PRIMARY KEY,"
|
"id INTEGER PRIMARY KEY,"
|
||||||
"username TEXT,"
|
"username TEXT,"
|
||||||
"pw_hash TEXT,"
|
"pw_hash TEXT,"
|
||||||
"admin BOOL DEFAULT FALSE)")
|
"admin BOOL DEFAULT FALSE,"
|
||||||
|
"token)")
|
||||||
|
|
||||||
db_execute("CREATE TABLE uploads("
|
db_execute("CREATE TABLE uploads("
|
||||||
"filename TEXT,"
|
"filename TEXT,"
|
||||||
|
@ -127,6 +127,10 @@ def init():
|
||||||
t.start()
|
t.start()
|
||||||
app.config["CRON_THREAD"] = t
|
app.config["CRON_THREAD"] = t
|
||||||
|
|
||||||
|
# init paranoid
|
||||||
|
app.config["paranoid"] = Paranoid(app)
|
||||||
|
app.config["paranoid"].redirect_view = 'login'
|
||||||
|
|
||||||
|
|
||||||
def add_user(username, password, admin="FALSE"):
|
def add_user(username, password, admin="FALSE"):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user