Code Monkey home page Code Monkey logo

Comments (10)

jrhone avatar jrhone commented on May 18, 2024 2

@andfanilo Can you run the following in your terminal and share the output?
python -c "import mimetypes; print (mimetypes.guess_type('lunr.js'))"

It should return ('application/javascript', None)

If not, can you try the instructions here? But create the mime type for javascript not for pdf

from docs.

jrhone avatar jrhone commented on May 18, 2024

Hmm it works for me locally

  • Mac, Firefox
  • Python 3.7.4
  • Streamlit 0.57.3

And on my Windows VM

  • Windows 10, Firefox
  • Python 3.8
  • Streamlit 0.57.3

from docs.

arraydude avatar arraydude commented on May 18, 2024

It is working fine also for me:

  • Mac, Chrome & Firefox
  • Python 3.8.2
  • Streamlit 0.57.3

from docs.

andfanilo avatar andfanilo commented on May 18, 2024

Works like a charm, thanks @jrhone ! Guess one of my IDEs wanted to have fun with file extensions...

from docs.

jrhone avatar jrhone commented on May 18, 2024

Well, seems like Firefox added some new security features and your OS didn't have Mime Types configured correctly.

I wonder if we should add this to the documentation somewhere or automate this check if possible and provide a warning to the user.

Going to re-open for now so we can address the scenario fully.

Thanks for confirming the fix!

from docs.

andfanilo avatar andfanilo commented on May 18, 2024

This may explain things, so for other readers I was on Firefox 75 here and python -c "import mimetypes; print (mimetypes.guess_type('lunr.js'))" returned text/plain.

from docs.

randyzwitch avatar randyzwitch commented on May 18, 2024

Going to close this, since it hasn't come up again since I've been at the company. Obviously, if people start mentioning this again, we can add a note to the docs

from docs.

GuyYeates avatar GuyYeates commented on May 18, 2024

Graphviz not showing in Chrome (Version 80.0.3987.132 (Official Build) (64-bit) ).

Code built from Visual Studio Code on Windows 10 machine.

Code used was from https://docs.streamlit.io/en/stable/api.html#streamlit.graphviz_chart
Running python -c "import mimetypes; print (mimetypes.guess_type('lunr.js'))" in console returned "text/plain"

Registry changes
.js node was present under "HKEY_LOCAL_MACHINE" at Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes.js
I added "ContentType" key with a value of 'application/javascript'

Re-tested with no effect. Opened a new command prompt and re-ran python -c "import mimetypes; print (mimetypes.guess_type('lunr.js'))" which returned "text/plain"

.js node was present in "HKEY_CURRENT_USER" at Checked Computer\HKEY_CURRENT_USER\SOFTWARE\Classes.js
and it had these values "ContentType" = 'text/plain' and "PerceivedType" = 'text'
Changed the ContentType value to 'application/javascript'
Re-tested with no effect. Opened a new command prompt and re-ran python -c "import mimetypes; print (mimetypes.guess_type('lunr.js'))" which returned "text/plain"

Re-set the registry back to the initial position
I ran the app in (chromium) version of Edge and the graph(s) shows as expected

addendum...

Please note in the change in the registry to set .js files to "application/javascript" will allow .js files to run on a machine on a double-click and this has security issues (which is why the mime type for .js files is to "plain text" on my machine). My home laptop has no mimetype set for .js and the graph displays as expected in Chrome (unsure if its version however). If that helps.

Update
Now I find that despite root, local machine and user class entries in registry have .js set to 'application/javascript' Microsoft Edge and Chrome no longer displays the GraphViz graphs

from docs.

johnpyrce avatar johnpyrce commented on May 18, 2024

This failed for me with the above symptoms as well.

Windows 10 PC
streamlit 0.76.0

The HKEY_LOCAL_MACHINE/Software/Classes/.js key was correct, but a HKEY_CURRENT_USER/Software/Classes/.js key was "text/plain". I changed this in the registry.

Now the python script reports "('application/javascript', None)". Chrome and Firefox display the chart. But this still fails in the same way in Microsoft Edge (which is what I use by default).
Edge 88.0.705.63
Chrome Version 88.0.4324.150

Javascript console errors in Edge are:

4fc2c1f8-4a0c-487a-8f3f-1c1cc2f7ae8c:4 Refused to execute script from 'http://localhost:8501/vendor/viz/viz-1.8.0.min.js' because its MIME type ('text/plain') is not executable.
onmessage @ 4fc2c1f8-4a0c-487a-8f3f-1c1cc2f7ae8c:4
4fc2c1f8-4a0c-487a-8f3f-1c1cc2f7ae8c:4 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8501/vendor/viz/viz-1.8.0.min.js' failed to load.
at onmessage (blob:http://localhost:8501/4fc2c1f8-4a0c-487a-8f3f-1c1cc2f7ae8c:4:21)
15.4f7ab330.chunk.js:1 Uncaught Viz is not defined

from docs.

snehankekre avatar snehankekre commented on May 18, 2024

Closing this issue as one already exists in the Streamlit library repo: streamlit/streamlit#3887

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.