mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-07 22:30:00 +00:00
Centralize MIME type initialization into utils/mime_types.py
Move mimetypes.init() and all custom type registrations from server.py and metadata_extract.py into a single init_mime_types() function called once at startup in main.py. Amp-Thread-ID: https://ampcode.com/threads/T-019cbb2a-513a-7458-9962-b4100e4f124d Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
37
utils/mime_types.py
Normal file
37
utils/mime_types.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Centralized MIME type initialization.
|
||||
|
||||
Call init_mime_types() once at startup to initialize the MIME type database
|
||||
and register all custom types used across ComfyUI.
|
||||
"""
|
||||
|
||||
import mimetypes
|
||||
|
||||
_initialized = False
|
||||
|
||||
|
||||
def init_mime_types():
|
||||
"""Initialize the MIME type database and register all custom types.
|
||||
|
||||
Safe to call multiple times; only runs once.
|
||||
"""
|
||||
global _initialized
|
||||
if _initialized:
|
||||
return
|
||||
_initialized = True
|
||||
|
||||
mimetypes.init()
|
||||
|
||||
# Web types (used by server.py for static file serving)
|
||||
mimetypes.add_type('application/javascript; charset=utf-8', '.js')
|
||||
mimetypes.add_type('image/webp', '.webp')
|
||||
|
||||
# Model and data file types (used by asset scanning / metadata extraction)
|
||||
mimetypes.add_type("application/safetensors", ".safetensors")
|
||||
mimetypes.add_type("application/safetensors", ".sft")
|
||||
mimetypes.add_type("application/pytorch", ".pt")
|
||||
mimetypes.add_type("application/pytorch", ".pth")
|
||||
mimetypes.add_type("application/pickle", ".ckpt")
|
||||
mimetypes.add_type("application/pickle", ".pkl")
|
||||
mimetypes.add_type("application/gguf", ".gguf")
|
||||
mimetypes.add_type("application/yaml", ".yaml")
|
||||
mimetypes.add_type("application/yaml", ".yml")
|
||||
Reference in New Issue
Block a user