Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Blank page and MIME type error when running SampleApp with ReactPy on Python 3.10.5 and Windows 10 #1073

Answered by sn0vv
sn0vv asked this question in Problem
Discussion options

Hello,

I install reactpy on Python 3.10.5 and Windows 10.

pip install "reactpy[starlette]"

I run the sample application.

python -c "import reactpy; reactpy.run(reactpy.sample.SampleApp)"

But Chrome shows a blank page and DevTools Console outputs the following:

index.a1f87a11.js:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.

Visual Studio Code TERMINAL outputs the following:

(venv_react) PS D:\dev\python\reactpy\venv_react> python -c "import reactpy; reactpy.run(reactpy.sample.SampleApp)"
2023年06月19日T22:23:33+0900 | WARNING | The run() function is only intended for testing during development! To run in production, consider selecting a supported backend and importing its associated configure() function from reactpy.backend.<package> where <package> is one of ['starlette', 'fastapi', 'sanic', 'tornado', 'flask']. For details refer to the docs on how to run each package.
2023年06月19日T22:23:33+0900 | INFO | Running with starlette.applications.Starlette at http://127.0.0.1:8000
INFO: Started server process [31804]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:63690 - "GET / HTTP/1.1" 200 OK
INFO: 127.0.0.1:63690 - "GET /index.a1f87a11.js HTTP/1.1" 304 Not Modified

Please let me know what is wrong.
Thanks in advance.

You must be logged in to vote

I installed reactpy v1.0.1 and followed these steps:

  1. I used regedit to navigate to HKEY_CLASSES_ROOT/.js and edited the String Value key.
    Name: Content Type
    Value: Changed "text/plain" to "application/javascript"

  2. However, the Chrome DevTools Console still showed an error.

  3. I tried using Microsoft Edge instead, and it worked!

Thanks.

Replies: 2 comments 3 replies

Comment options

We've seen this reported by Windows users (accept this discord invite if you haven't already) a number of times. This typically occurs when your mimetype registry has been corrupted (often by VisualStudio). We recently released a patch (v1.0.1) that should work around the corrupted registry. With that said, you should try and fix the registry itself since most other libraries do not attempt to work around the corrupted registry.

If, after upgrading to ReactPy 1.0.1, have fixed your corrupted registry, and are still experiencing issues, try running the page in a private browser (i.e. without extensions). If the page renders, then you may want to try uninstalling extensions, or re-installing your browser.

You must be logged in to vote
0 replies
Comment options

I installed reactpy v1.0.1 and followed these steps:

  1. I used regedit to navigate to HKEY_CLASSES_ROOT/.js and edited the String Value key.
    Name: Content Type
    Value: Changed "text/plain" to "application/javascript"

  2. However, the Chrome DevTools Console still showed an error.

  3. I tried using Microsoft Edge instead, and it worked!

Thanks.

You must be logged in to vote
3 replies
Comment options

I also encountered this problem.

I followed that guide and the problem persisted, either edge or chrome. I am still looking for a solution.

Comment options

My current fix is to use other port number than 8000 as port 8000 does not work.

Something like this, using port 7000 will work.

python -c "import reactpy; reactpy.run(reactpy.sample.SampleApp, port=7000)"

Similar issue is at #1046 (comment)

Comment options

What works for me now without changing ports is remove

Name: Content Type
Value: Changed "text/plain" to "application/javascript"

from .js

Answer selected by rmorshea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /