Alert when new photos are uploaded
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
blinker==1.8.2
|
||||
certifi==2026.1.4
|
||||
charset-normalizer==3.4.4
|
||||
click==8.1.7
|
||||
flask==3.0.3
|
||||
idna==3.11
|
||||
importlib-metadata==8.0.0
|
||||
itsdangerous==2.2.0
|
||||
jinja2==3.1.4
|
||||
MarkupSafe==2.1.5
|
||||
pillow==10.3.0
|
||||
requests==2.32.5
|
||||
urllib3==2.6.3
|
||||
werkzeug==3.0.3
|
||||
zipp==3.19.2
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import random
|
||||
import string
|
||||
import requests
|
||||
|
||||
from flask import abort, Flask, request, redirect
|
||||
from pathlib import Path
|
||||
@@ -16,6 +17,17 @@ URL = 'https://pic.t0.vc'
|
||||
POST_PARAM = 'pic'
|
||||
MAX_FILE_SIZE = 16 * 1024 * 1024 # 16 MB
|
||||
|
||||
def controller_message(message):
|
||||
print('Sending controller message: ' + message)
|
||||
payload = dict(pic=message)
|
||||
r = requests.post('https://tbot.tannercollin.com/message', data=payload, timeout=5)
|
||||
if r.status_code == 200:
|
||||
return True
|
||||
else:
|
||||
print('Unable to communicate with controller!')
|
||||
return False
|
||||
|
||||
|
||||
def help():
|
||||
form = (
|
||||
f'<form action="{URL}" method="POST" accept-charset="UTF-8" enctype="multipart/form-data">'
|
||||
@@ -58,7 +70,6 @@ EXAMPLES
|
||||
SOURCE CODE
|
||||
https://txt.t0.vc/CQQE
|
||||
nginx config: https://txt.t0.vc/ZKEH
|
||||
https://github.com/tannercollin/t0pic
|
||||
|
||||
SEE ALSO
|
||||
https://txt.t0.vc
|
||||
@@ -133,6 +144,11 @@ def new():
|
||||
print(f'Adding pic {nid}{ext}')
|
||||
|
||||
url = f'{URL}/{nid}{ext}'
|
||||
|
||||
if pic.size != (300, 150):
|
||||
msg = 'New t0pic:\n\n' + url
|
||||
controller_message(msg)
|
||||
|
||||
if 'web' in request.form:
|
||||
return redirect(url)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user