Compare commits
2 Commits
8d01dfbd33
...
0da549d20d
Author | SHA1 | Date | |
---|---|---|---|
0da549d20d | |||
47d3dc5b0b |
|
@ -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```
|
```passlib argon2_cffi flask gunicorn flask-paranoid apscheduler requests```
|
||||||
|
|
||||||
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,7 +344,12 @@ 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 e
|
return str(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 = []
|
||||||
|
|
||||||
|
@ -354,8 +359,10 @@ 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":
|
if request.form.get("randname") == "on" or request.form.get("text"):
|
||||||
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
|
||||||
|
|
||||||
|
@ -448,6 +455,17 @@ 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,7 +20,8 @@
|
||||||
<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>
|
</select><br>
|
||||||
|
<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