Skip to content

Commit 5160513

Browse files
committed
refac
1 parent 0130b49 commit 5160513

6 files changed

Lines changed: 304 additions & 206 deletions

File tree

backend/open_webui/main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
ENABLE_SCIM,
9393
ENABLE_SIGNUP_PASSWORD_CONFIRMATION,
9494
ENABLE_STAR_SESSIONS_MIDDLEWARE,
95+
ENABLE_PYODIDE_FILE_PERSISTENCE,
9596
ENABLE_VERSION_UPDATE_CHECK,
9697
ENABLE_WEBSOCKET_SUPPORT,
9798
GLOBAL_LOG_LEVEL,
@@ -271,6 +272,13 @@ async def get_response(self, path: str, scope):
271272
raise ex
272273

273274

275+
class CORSStaticFiles(StaticFiles):
276+
async def get_response(self, path: str, scope):
277+
response = await super().get_response(path, scope)
278+
response.headers['Access-Control-Allow-Origin'] = '*'
279+
return response
280+
281+
274282
if LOG_FORMAT != 'json':
275283
banner = rf"""
276284
██████╗ ██████╗ ███████╗███╗ ██╗ ██╗ ██╗███████╗██████╗ ██╗ ██╗██╗
@@ -2580,6 +2588,10 @@ def swagger_ui_html(*args, **kwargs):
25802588

25812589
if os.path.exists(FRONTEND_BUILD_DIR):
25822590
mimetypes.add_type('text/javascript', '.js')
2591+
pyodide_dir = FRONTEND_BUILD_DIR / 'pyodide'
2592+
if os.path.exists(pyodide_dir):
2593+
app.mount('/pyodide', CORSStaticFiles(directory=pyodide_dir), name='pyodide')
2594+
25832595
app.mount(
25842596
'/',
25852597
SPAStaticFiles(directory=FRONTEND_BUILD_DIR, html=True),
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { get } from 'svelte/store';
2+
3+
import { config } from '$lib/stores';
4+
import { PyodideSandboxHost } from '$lib/pyodide/pyodideSandboxHost';
5+
import PyodideWorker from '$lib/workers/pyodide.worker?worker';
6+
7+
export const createPyodideWorker = (): Worker =>
8+
get(config)?.features?.enable_pyodide_file_persistence
9+
? new PyodideWorker()
10+
: (new PyodideSandboxHost() as unknown as Worker);

src/lib/pyodide/pyodideKernel.ts

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/lib/pyodide/pyodideKernel.worker.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)