Alert when new photos are uploaded

This commit is contained in:
2026-01-24 18:35:32 +00:00
parent 2fab3fa0d1
commit 06b4cf08b9
2 changed files with 22 additions and 1 deletions
+5
View File
@@ -1,10 +1,15 @@
blinker==1.8.2 blinker==1.8.2
certifi==2026.1.4
charset-normalizer==3.4.4
click==8.1.7 click==8.1.7
flask==3.0.3 flask==3.0.3
idna==3.11
importlib-metadata==8.0.0 importlib-metadata==8.0.0
itsdangerous==2.2.0 itsdangerous==2.2.0
jinja2==3.1.4 jinja2==3.1.4
MarkupSafe==2.1.5 MarkupSafe==2.1.5
pillow==10.3.0 pillow==10.3.0
requests==2.32.5
urllib3==2.6.3
werkzeug==3.0.3 werkzeug==3.0.3
zipp==3.19.2 zipp==3.19.2
+17 -1
View File
@@ -3,6 +3,7 @@
import random import random
import string import string
import requests
from flask import abort, Flask, request, redirect from flask import abort, Flask, request, redirect
from pathlib import Path from pathlib import Path
@@ -16,6 +17,17 @@ URL = 'https://pic.t0.vc'
POST_PARAM = 'pic' POST_PARAM = 'pic'
MAX_FILE_SIZE = 16 * 1024 * 1024 # 16 MB 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(): def help():
form = ( form = (
f'<form action="{URL}" method="POST" accept-charset="UTF-8" enctype="multipart/form-data">' f'<form action="{URL}" method="POST" accept-charset="UTF-8" enctype="multipart/form-data">'
@@ -58,7 +70,6 @@ EXAMPLES
SOURCE CODE SOURCE CODE
https://txt.t0.vc/CQQE https://txt.t0.vc/CQQE
nginx config: https://txt.t0.vc/ZKEH nginx config: https://txt.t0.vc/ZKEH
https://github.com/tannercollin/t0pic
SEE ALSO SEE ALSO
https://txt.t0.vc https://txt.t0.vc
@@ -133,6 +144,11 @@ def new():
print(f'Adding pic {nid}{ext}') print(f'Adding pic {nid}{ext}')
url = f'{URL}/{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: if 'web' in request.form:
return redirect(url) return redirect(url)
else: else: