photolib/photoapp/webutils.py

22 lines
773 B
Python
Raw Normal View History

import os
import cherrypy
from photoapp.types import APPROOT, User
from photoapp.dbutils import db
from photoapp.common import pwhash
def validate_password(realm, username, password):
if db.query(User).filter(User.name == username, User.password == pwhash(password)).first():
return True
return False
def serve_thumbnail_placeholder(temporary=False):
"""
Serve the placeholder for broken/unavailable thumbnails, the <?> image. Setting temporary will add a no-cache header
"""
if temporary:
cherrypy.response.headers["Cache-Control"] = "no-store, must-revalidate, max-age=0"
cherrypy.response.headers["Age"] = "0"
return cherrypy.lib.static.serve_file(os.path.join(APPROOT, "assets/img/unknown.svg"), "image/svg+xml")