Skip to content

Unable to load local directory on Mac OSX #9

@Chadius

Description

@Chadius

Environment: Mac OSX 15.1
Browser: Safari, Firefox, Chrome

When I click "Select Local Images" the app crashes.

Network tab says it's trying to make a POST call to "/select_directory", but the request is getting blocked on my end. I think this is a CORS issue where localhost will block other localhost calls.

The browser error looks like this:

    <anonymous> http://localhost:5000/:362
    (Async: promise callback)
    <anonymous> http://localhost:5000/:361

Here's my terminal output.

 * Serving Flask app 'app'
 * Debug mode: off
INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
INFO:werkzeug:Press CTRL+C to quit
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /static/style.css HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /static/click.mp3 HTTP/1.1" 206 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_images HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_rankings HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /serve_image?path=static/images/40e0ab70-0c75-4634-ab8f-1157699f3f8c.jpg HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /serve_image?path=static/images/45e6ea01-257e-4ed0-95e9-7620eb360772.jpg HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /get_current_directory HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [12/Nov/2024 06:56:54] "GET /favicon.ico HTTP/1.1" 404 -
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000018799cec0 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x0000000187482cd8 objc_exception_throw + 88
	2   CoreFoundation                      0x00000001879c154c _CFBundleGetValueForInfoKey + 0
	3   AppKit                              0x000000018b47e6f4 -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 260
	4   AppKit                              0x000000018b47e5e4 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 48
	5   libtk8.6.dylib                      0x0000000102c71ba4 TkMacOSXMakeRealWindowExist + 564
	6   libtk8.6.dylib                      0x0000000102c717f0 TkWmMapWindow + 76
	7   libtk8.6.dylib                      0x0000000102bce588 MapFrame + 76
	8   libtcl8.6.dylib                     0x0000000102f9b1a0 TclServiceIdle + 88
	9   libtcl8.6.dylib                     0x0000000102f7b09c Tcl_DoOneEvent + 120
	10  libtk8.6.dylib                      0x0000000102c629c8 TkpInit + 800
	11  libtk8.6.dylib                      0x0000000102bc6f20 Initialize + 2500
	12  _tkinter.cpython-312-darwin.so      0x0000000101b2a1b8 Tcl_AppInit + 92
	13  _tkinter.cpython-312-darwin.so      0x0000000101b29e08 Tkapp_New + 668
	14  _tkinter.cpython-312-darwin.so      0x0000000101b29b68 _tkinter_create_impl + 268
	15  _tkinter.cpython-312-darwin.so      0x0000000101b297e8 _tkinter_create + 276
	16  python3.12                          0x00000001003e29ac cfunction_vectorcall_FASTCALL + 96
	17  python3.12                          0x00000001004eb670 _PyEval_EvalFrameDefault + 221860
	18  python3.12                          0x00000001004125f0 slot_tp_init + 328
	19  python3.12                          0x0000000100406858 type_call + 148
	20  python3.12                          0x00000001004eba10 _PyEval_EvalFrameDefault + 222788
	21  python3.12                          0x000000010037f900 method_vectorcall + 368
	22  python3.12                          0x00000001005f7944 thread_run + 156
	23  python3.12                          0x0000000100577cfc pythread_wrapper + 48
	24  libsystem_pthread.dylib             0x00000001878432e4 _pthread_start + 136
	25  libsystem_pthread.dylib             0x000000018783e0fc thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
[1]    87579 abort      python app.py

I feel the solution is to configure the call to select_directory so it passes CORS restrictions but I'm not completely sure on how to do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions