Compare commits
No commits in common. "0da549d20d102fd60a245fd12e36f2ce9893f180" and "8d01dfbd33f8ac93f42bb83f4949e0caf7ee299d" have entirely different histories.
0da549d20d
...
8d01dfbd33
|
@ -6,6 +6,6 @@ Note: I switched to Gunicorn at some point because Bjoern was somehow annoying.
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
|
|
||||||
```passlib argon2_cffi flask gunicorn flask-paranoid apscheduler requests```
|
```passlib argon2_cffi flask gunicorn flask-paranoid apscheduler```
|
||||||
|
|
||||||
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`.
|
||||||
|
|
22
fileHost.py
22
fileHost.py
|
@ -344,12 +344,7 @@ def upload():
|
||||||
try:
|
try:
|
||||||
f = [download_file(request.form.get("url"))]
|
f = [download_file(request.form.get("url"))]
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
return str(e)
|
return e
|
||||||
if request.form.get("text"):
|
|
||||||
try:
|
|
||||||
f = [text_paste(request.form.get("text"))]
|
|
||||||
except Exception as e:
|
|
||||||
return str(e)
|
|
||||||
else:
|
else:
|
||||||
f = []
|
f = []
|
||||||
|
|
||||||
|
@ -359,10 +354,8 @@ def upload():
|
||||||
pre = get_rand_chars(8)
|
pre = get_rand_chars(8)
|
||||||
fdir = app.config.get("UPLOAD_DIR")
|
fdir = app.config.get("UPLOAD_DIR")
|
||||||
|
|
||||||
if request.form.get("randname") == "on" or request.form.get("text"):
|
if request.form.get("randname") == "on":
|
||||||
fname = pre + os.path.splitext(fname)[1]
|
fname = pre + os.path.splitext(fname)[1]
|
||||||
if request.form.get("text"):
|
|
||||||
fname += ".txt"
|
|
||||||
else:
|
else:
|
||||||
fname = pre + "_" + fname
|
fname = pre + "_" + fname
|
||||||
|
|
||||||
|
@ -455,17 +448,6 @@ def download_file(url):
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
def text_paste(text):
|
|
||||||
"""
|
|
||||||
Simple wrapper to handle a text paste upload.
|
|
||||||
"""
|
|
||||||
t = tempfile.TemporaryFile()
|
|
||||||
t.write(bytes(text, encoding='utf8'))
|
|
||||||
t.seek(0)
|
|
||||||
f = FileStorage(stream=t, filename="", name='text')
|
|
||||||
return f
|
|
||||||
|
|
||||||
|
|
||||||
init()
|
init()
|
||||||
atexit.register(scheduler.shutdown)
|
atexit.register(scheduler.shutdown)
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
<option value="hour">Hour</option>
|
<option value="hour">Hour</option>
|
||||||
<option value="day" selected="selected">Day</option>
|
<option value="day" selected="selected">Day</option>
|
||||||
<option value="week">Week</option>
|
<option value="week">Week</option>
|
||||||
</select><br>
|
</select>
|
||||||
<textarea name="text"></textarea><br>
|
|
||||||
<input type="hidden" name="html" value="on">
|
<input type="hidden" name="html" value="on">
|
||||||
<p><input type="submit" value="Upload File" name="submit">
|
<p><input type="submit" value="Upload File" name="submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user