mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-12-25 16:38:55 +01:00
Don't log thumbnail requests into the access log, makes it hard to answer support queries since the server and access logs are the same right now
This commit is contained in:
parent
88d59eb7fa
commit
102e454902
20
ui/server.py
20
ui/server.py
@ -30,6 +30,11 @@ model_is_loading = False
|
|||||||
modifiers_cache = None
|
modifiers_cache = None
|
||||||
outpath = os.path.join(os.path.expanduser("~"), OUTPUT_DIRNAME)
|
outpath = os.path.join(os.path.expanduser("~"), OUTPUT_DIRNAME)
|
||||||
|
|
||||||
|
# don't show access log entries for URLs that start with the given prefix
|
||||||
|
ACCESS_LOG_SUPPRESS_PATH_PREFIXES = ['/ping', '/modifier-thumbnails']
|
||||||
|
|
||||||
|
app.mount('/media', StaticFiles(directory=os.path.join(SD_UI_DIR, 'media/')), name="media")
|
||||||
|
|
||||||
# defaults from https://huggingface.co/blog/stable_diffusion
|
# defaults from https://huggingface.co/blog/stable_diffusion
|
||||||
class ImageRequest(BaseModel):
|
class ImageRequest(BaseModel):
|
||||||
session_id: str = "session"
|
session_id: str = "session"
|
||||||
@ -59,8 +64,6 @@ class ImageRequest(BaseModel):
|
|||||||
class SetAppConfigRequest(BaseModel):
|
class SetAppConfigRequest(BaseModel):
|
||||||
update_branch: str = "main"
|
update_branch: str = "main"
|
||||||
|
|
||||||
app.mount('/media', StaticFiles(directory=os.path.join(SD_UI_DIR, 'media/')), name="media")
|
|
||||||
|
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
def read_root():
|
def read_root():
|
||||||
headers = {"Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0"}
|
headers = {"Cache-Control": "no-cache, no-store, must-revalidate", "Pragma": "no-cache", "Expires": "0"}
|
||||||
@ -213,12 +216,17 @@ def read_modifiers():
|
|||||||
def read_home_dir():
|
def read_home_dir():
|
||||||
return {outpath}
|
return {outpath}
|
||||||
|
|
||||||
# don't log /ping requests
|
# don't log certain requests
|
||||||
class HealthCheckLogFilter(logging.Filter):
|
class LogSuppressFilter(logging.Filter):
|
||||||
def filter(self, record: logging.LogRecord) -> bool:
|
def filter(self, record: logging.LogRecord) -> bool:
|
||||||
return record.getMessage().find('/ping') == -1
|
path = record.getMessage()
|
||||||
|
for prefix in ACCESS_LOG_SUPPRESS_PATH_PREFIXES:
|
||||||
|
if path.find(prefix) != -1:
|
||||||
|
return False
|
||||||
|
|
||||||
logging.getLogger('uvicorn.access').addFilter(HealthCheckLogFilter())
|
return True
|
||||||
|
|
||||||
|
logging.getLogger('uvicorn.access').addFilter(LogSuppressFilter())
|
||||||
|
|
||||||
# start the browser ui
|
# start the browser ui
|
||||||
import webbrowser; webbrowser.open('http://localhost:9000')
|
import webbrowser; webbrowser.open('http://localhost:9000')
|
Loading…
Reference in New Issue
Block a user