-
-
diff --git a/invokeai/app/api_app.py b/invokeai/app/api_app.py index e07b037dd1..f45541e63b 100644 --- a/invokeai/app/api_app.py +++ b/invokeai/app/api_app.py @@ -23,6 +23,7 @@ if True: # hack to make flake8 happy with imports coming after setting up the c from fastapi_events.handlers.local import local_handler from fastapi_events.middleware import EventHandlerASGIMiddleware from pydantic.json_schema import models_json_schema + from fastapi.responses import FileResponse # noinspection PyUnresolvedReferences import invokeai.backend.util.hotfixes # noqa: F401 (monkeypatching on import) @@ -173,16 +174,13 @@ def custom_openapi(): app.openapi = custom_openapi # type: ignore [method-assign] # this is a valid assignment -# Override API doc favicons -app.mount("/static", StaticFiles(directory=Path(web_dir.__path__[0], "static/dream_web")), name="static") - @app.get("/docs", include_in_schema=False) def overridden_swagger(): return get_swagger_ui_html( openapi_url=app.openapi_url, title=app.title, - swagger_favicon_url="/static/favicon.ico", + swagger_favicon_url="/static/docs/favicon.ico", ) @@ -191,12 +189,24 @@ def overridden_redoc(): return get_redoc_html( openapi_url=app.openapi_url, title=app.title, - redoc_favicon_url="/static/favicon.ico", + redoc_favicon_url="/static/docs/favicon.ico", ) -# Must mount *after* the other routes else it borks em -app.mount("/", StaticFiles(directory=Path(web_dir.__path__[0], "dist"), html=True), name="ui") +web_root_path = Path(list(web_dir.__path__)[0]) + + +# Cannot add headers to StaticFiles, so we must serve index.html with a custom route +# Add cache-control: no-store header to prevent caching of index.html, which leads to broken UIs at release +@app.get("/", include_in_schema=False, name="ui_root") +def get_index() -> FileResponse: + return FileResponse(Path(web_root_path, "dist/index.html"), headers={"Cache-Control": "no-store"}) + + +# # Must mount *after* the other routes else it borks em +app.mount("/static", StaticFiles(directory=Path(web_root_path, "static/")), name="static") # docs favicon is in here +app.mount("/assets", StaticFiles(directory=Path(web_root_path, "dist/assets/")), name="assets") +app.mount("/locales", StaticFiles(directory=Path(web_root_path, "dist/locales/")), name="locales") def invoke_api(): diff --git a/invokeai/frontend/web/static/dream_web/favicon.ico b/invokeai/frontend/web/static/docs/favicon.ico similarity index 100% rename from invokeai/frontend/web/static/dream_web/favicon.ico rename to invokeai/frontend/web/static/docs/favicon.ico diff --git a/invokeai/frontend/web/static/dream_web/index.css b/invokeai/frontend/web/static/dream_web/index.css deleted file mode 100644 index 25a0994a3d..0000000000 --- a/invokeai/frontend/web/static/dream_web/index.css +++ /dev/null @@ -1,179 +0,0 @@ -:root { - --fields-dark:#DCDCDC; - --fields-light:#F5F5F5; -} - -* { - font-family: 'Arial'; - font-size: 100%; -} -body { - font-size: 1em; -} -textarea { - font-size: 0.95em; -} -header, form, #progress-section { - margin-left: auto; - margin-right: auto; - max-width: 1024px; - text-align: center; -} -fieldset { - border: none; - line-height: 2.2em; -} -fieldset > legend { - width: auto; - margin-left: 0; - margin-right: auto; - font-weight:bold; -} -select, input { - margin-right: 10px; - padding: 2px; -} -input:disabled { - cursor:auto; -} -input[type=submit] { - cursor: pointer; - background-color: #666; - color: white; -} -input[type=checkbox] { - cursor: pointer; - margin-right: 0px; - width: 20px; - height: 20px; - vertical-align: middle; -} -input#seed { - margin-right: 0px; -} -div { - padding: 10px 10px 10px 10px; -} -header { - margin-bottom: 16px; -} -header h1 { - margin-bottom: 0; - font-size: 2em; -} -#search-box { - display: flex; -} -#scaling-inprocess-message { - font-weight: bold; - font-style: italic; - display: none; -} -#prompt { - flex-grow: 1; - padding: 5px 10px 5px 10px; - border: 1px solid #999; - outline: none; -} -#submit { - padding: 5px 10px 5px 10px; - border: 1px solid #999; -} -#reset-all, #remove-image { - margin-top: 12px; - font-size: 0.8em; - background-color: pink; - border: 1px solid #999; - border-radius: 4px; -} -#results { - text-align: center; - margin: auto; - padding-top: 10px; -} -#results figure { - display: inline-block; - margin: 10px; -} -#results figcaption { - font-size: 0.8em; - padding: 3px; - color: #888; - cursor: pointer; -} -#results img { - border-radius: 5px; - object-fit: contain; - background-color: var(--fields-dark); -} -#fieldset-config { - line-height:2em; -} -input[type="number"] { - width: 60px; -} -#seed { - width: 150px; -} -button#reset-seed { - font-size: 1.7em; - background: #efefef; - border: 1px solid #999; - border-radius: 4px; - line-height: 0.8; - margin: 0 10px 0 0; - padding: 0 5px 3px; - vertical-align: middle; -} -label { - white-space: nowrap; -} -#progress-section { - display: none; -} -#progress-image { - width: 30vh; - height: 30vh; - object-fit: contain; - background-color: var(--fields-dark); -} -#cancel-button { - cursor: pointer; - color: red; -} -#txt2img { - background-color: var(--fields-dark); -} -#variations { - background-color: var(--fields-light); -} -#initimg { - background-color: var(--fields-dark); -} -#img2img { - background-color: var(--fields-light); -} -#initimg > :not(legend) { - background-color: var(--fields-light); - margin: .5em; -} - -#postprocess, #initimg { - display:flex; - flex-wrap:wrap; - padding: 0; - margin-top: 1em; - background-color: var(--fields-dark); -} -#postprocess > fieldset, #initimg > * { - flex-grow: 1; -} -#postprocess > fieldset { - background-color: var(--fields-dark); -} -#progress-section { - background-color: var(--fields-light); -} -#no-results-message:not(:only-child) { - display: none; -} diff --git a/invokeai/frontend/web/static/dream_web/index.html b/invokeai/frontend/web/static/dream_web/index.html deleted file mode 100644 index feb542adb2..0000000000 --- a/invokeai/frontend/web/static/dream_web/index.html +++ /dev/null @@ -1,187 +0,0 @@ - - -
-No results...
-