Repository: streamlit/streamlit

Issue:
Streamlit started giving 404: Not Found and no longer wants to work.
# Summary
Streamlit started giving 404: Not Found and no longer wants to work.

# Steps to reproduce
Added the multiselect example to my code:

```
options = st.multiselect(
    'What are your favorite colors',
    ('Yellow', 'Red')
    ('Green', 'Yellow', 'Red', 'Blue'))
st.write('You selected:', options)

```
## Expected behavior:
To get an app with a working multiselect

## Actual behavior:
App gives 404: Not Found and nothing I do wants to make it work again.

## Is this a regression?
yes

# Debug info
Streamlit version: 0.47.2
Python version: 3.7.1
Using Conda? PipEnv? PyEnv? Pex? pip on WinPython
OS version: Windows 10 version 1903
Browser version: Firefox 69.0

# Additional information
Tried changing the port, enabling debugging, killing the console and restarting. Not running jupyter-lab. Removing the multiselect code. Tried using `http://localhost:8501/?a=1`. Tried `http://192.168.1.34:8501`. Seems to be caching and always just returning the 404.

Streamlit started giving 404: Not Found and no longer wants to work.
# Summary
Streamlit started giving 404: Not Found and no longer wants to work.

# Steps to reproduce
Added the multiselect example to my code:

```
options = st.multiselect(
    'What are your favorite colors',
    ('Yellow', 'Red')
    ('Green', 'Yellow', 'Red', 'Blue'))
st.write('You selected:', options)

```
## Expected behavior:
To get an app with a working multiselect

## Actual behavior:
App gives 404: Not Found and nothing I do wants to make it work again.

## Is this a regression?
yes

# Debug info
Streamlit version: 0.47.2
Python version: 3.7.1
Using Conda? PipEnv? PyEnv? Pex? pip on WinPython
OS version: Windows 10 version 1903
Browser version: Firefox 69.0

# Additional information
Tried changing the port, enabling debugging, killing the console and restarting. Not running jupyter-lab. Removing the multiselect code. Tried using `http://localhost:8501/?a=1`. Tried `http://192.168.1.34:8501`. Seems to be caching and always just returning the 404.



Discussion:
.\streamlit hello now also 404's
`pip uninstall streamlit` and `pip install streamlit` also did not help
I am having the same issue, running on Anaconda but all other Debug info is the same otherwise. 
Thank you for this issue. @tvst is looking into this right now and we'll get back to you!
@Code4SAFrankie and @Hubes92 : Could you please try:

```bash
pip install streamlit==0.47.0
```
and see if that fixes the problem?
Also, we are still looking into this, but we believe this issue has to do with Windows, not your code snippet, @Code4SAFrankie.

After correcting a small bug in your code @Code4SAFrankie, I found that this worked for me (on MacOS):

```python
import streamlit as st

options = st.multiselect(
    'What are your favorite colors',
    ('Green', 'Yellow', 'Red', 'Blue'),
    ('Yellow', 'Red'))
st.write('You selected:', options)
```

![image](https://user-images.githubusercontent.com/1673013/66091690-aaa1b180-e53d-11e9-9a1c-3a83d517bb6b.png)

> @Code4SAFrankie and @Hubes92 : Could you please try:
> 
> ```shell
> pip install streamlit==0.47.0
> ```
> 
> and see if that fixes the problem?

Install 0.47.0 still gives me the same error unfortunately. 
Update: I was able to install Streamlit and run `streamlit hello` on a Windows VM without issues*.

*_Well that's not 100% true... I ran into this #236 , but that's not Windows-specific and we have a fix coming out!_

Then I re-read the issue and realized you're using something called WinPython — so let me try that tomorrow.

Clearly I'm not a Windows expert :baby: , apologies for the delay!
> Update: I was able to install Streamlit and run `streamlit hello` on a Windows VM without issues*.
> 
> *_Well that's not 100% true... I ran into this #236 , but that's not Windows-specific and we have a fix coming out!_
> 
> Then I re-read the issue and realized you're using something called WinPython — so let me try that tomorrow.
> 
> Clearly I'm not a Windows expert 👶 , apologies for the delay!

@tvst Im having the same issue but Im not using WinPython, I run with anaconda. The config.py also  hard codes the port in to 8051, I changed it in that script to see if that helps but it didnt. I also found that the address was hard coded to localHost and changed to various other valid localhost addresses in Server.py etc but that didnt help either. Hope it helps somewhat or might just be useless information. 
You probably already checked this, but just to get the obvious things out of the way: can you make sure Windows Firewall is not blocking Streamlit?

I noticed that when I first ran a Streamlit app on Windows I had to click through a dialog to allow it to use port 8501. I don't know if there's some situation that would cause the firewall to revoke that permission behind the scenes...
Yeah @tvst double checked that and changed the port as well in case that was the cause. 
Facing the same issue
Same here. Win10 / Python 3.7.1

`$ pip install streamlit`
`$ streamlit hello`

I also tried the version 0.47.0 but same 404: Not Found
Firewall not blocking port 8501
Windows 10 / Python 3.6.7

Running "streamlit hello", gives me 404 error. 
`404: Not Found`
Note that you can't run jupyter-lab and streamlit at the same time, since they both by default use the same port; but even getting the 404 without running jupyter-lab. Streamlit did initially work, but then stopped working and instead giving 404.
I've been able to get it to work while running JupyterLab by simply navigating to http://localhost:8501/index.html and then the page loads, otherwise its a 404.
Wow! Going to http://localhost:8501/index.html does not give me the 404 error, but instead correctly loads!!! Thanks!
@ismailuddin Thanks a million! It does work on http://localhost:8501/index.html 
> I've been able to get it to work while running JupyterLab by simply navigating to http://localhost:8501/index.html and then the page loads

Awesome, @ismailuddin !! Thanks for the work-around.

I'm still having problems reproducing the issue, though. So I have some more questions:
1. Did a previous version of Streamlit ever work? If so, can you downgrade and confirm? (When doing this, use `streamlit version` to double-check which version you're on)
2. Can you send me a HAR file for what happens when you go to `localhost:8501/` and when you go to `localhost:8501/index.html`?

Here's a page talking about how to grab a HAR file in different browsers: https://community.box.com/t5/Managing-Content-Troubleshooting/How-to-Generate-Network-Captures-for-Troubleshooting/ta-p/366

---
> Note that you can't run jupyter-lab and streamlit at the same time, since they both by default use the same port; 

Weird. On my machine, JupyterLab uses 8888 while Streamlit uses 8501. Are you saying they're both on 8501 on your machine?

Also, since version 0.47.0 Streamlit tries to find an open port when 8501 is taken. So even if JupyterLab is on that port Streamlit should run fine.

~Edit: I just realized the port-finder code isn't working on Python 2. We have a fix and will have it out with the next release.~ This is fixed since 0.47.4
Thank you @ismailuddin 
Yup on my machine Jupyter Lab is using port 8888 as well so it shouldn't actually be interfering. Tbh, I didn't actually try without JLab since it's practically always running on my laptop. Unfortunately I don't have access to my Windows machine for a few days so won't be able to try any of that out just yet. 
Sorry Jupyter Lab is using port 8888 on my machine.
Thanks, that makes sense! So I'm assuming the JupyterLab thing is a red herring at this point.

My best guess is that this would be fixed if we modified [this function call](https://github.com/streamlit/streamlit/blob/develop/lib/streamlit/server/Server.py#L236) in `streamlit/server/Server.py` to this:

```python
            routes.extend(
                [
                    (r"/(.*)", StaticFileHandler, {
                        "path": "%s/" % static_path,
                        "default_filename": "index.html",
                    }),
                ]
            )
```

But I can't repro the issue, so I can't verify that this fixes it. (Although we should probably do this anyway since it's cleaner than the current code!)

That said, if any enterprising soul would like verify that the above solves your problem, that would be amazing :smiley: 
That change fixes the issue for me.
.\streamlit hello now also 404's
`pip uninstall streamlit` and `pip install streamlit` also did not help
I am having the same issue, running on Anaconda but all other Debug info is the same otherwise. 
Thank you for this issue. @tvst is looking into this right now and we'll get back to you!
@Code4SAFrankie and @Hubes92 : Could you please try:

```bash
pip install streamlit==0.47.0
```
and see if that fixes the problem?
Also, we are still looking into this, but we believe this issue has to do with Windows, not your code snippet, @Code4SAFrankie.

After correcting a small bug in your code @Code4SAFrankie, I found that this worked for me (on MacOS):

```python
import streamlit as st

options = st.multiselect(
    'What are your favorite colors',
    ('Green', 'Yellow', 'Red', 'Blue'),
    ('Yellow', 'Red'))
st.write('You selected:', options)
```

![image](https://user-images.githubusercontent.com/1673013/66091690-aaa1b180-e53d-11e9-9a1c-3a83d517bb6b.png)

> @Code4SAFrankie and @Hubes92 : Could you please try:
> 
> ```shell
> pip install streamlit==0.47.0
> ```
> 
> and see if that fixes the problem?

Install 0.47.0 still gives me the same error unfortunately. 
Update: I was able to install Streamlit and run `streamlit hello` on a Windows VM without issues*.

*_Well that's not 100% true... I ran into this #236 , but that's not Windows-specific and we have a fix coming out!_

Then I re-read the issue and realized you're using something called WinPython — so let me try that tomorrow.

Clearly I'm not a Windows expert :baby: , apologies for the delay!
> Update: I was able to install Streamlit and run `streamlit hello` on a Windows VM without issues*.
> 
> *_Well that's not 100% true... I ran into this #236 , but that's not Windows-specific and we have a fix coming out!_
> 
> Then I re-read the issue and realized you're using something called WinPython — so let me try that tomorrow.
> 
> Clearly I'm not a Windows expert 👶 , apologies for the delay!

@tvst Im having the same issue but Im not using WinPython, I run with anaconda. The config.py also  hard codes the port in to 8051, I changed it in that script to see if that helps but it didnt. I also found that the address was hard coded to localHost and changed to various other valid localhost addresses in Server.py etc but that didnt help either. Hope it helps somewhat or might just be useless information. 
You probably already checked this, but just to get the obvious things out of the way: can you make sure Windows Firewall is not blocking Streamlit?

I noticed that when I first ran a Streamlit app on Windows I had to click through a dialog to allow it to use port 8501. I don't know if there's some situation that would cause the firewall to revoke that permission behind the scenes...
Yeah @tvst double checked that and changed the port as well in case that was the cause. 
Facing the same issue
Same here. Win10 / Python 3.7.1

`$ pip install streamlit`
`$ streamlit hello`

I also tried the version 0.47.0 but same 404: Not Found
Firewall not blocking port 8501
Windows 10 / Python 3.6.7

Running "streamlit hello", gives me 404 error. 
`404: Not Found`
Note that you can't run jupyter-lab and streamlit at the same time, since they both by default use the same port; but even getting the 404 without running jupyter-lab. Streamlit did initially work, but then stopped working and instead giving 404.
I've been able to get it to work while running JupyterLab by simply navigating to http://localhost:8501/index.html and then the page loads, otherwise its a 404.
Wow! Going to http://localhost:8501/index.html does not give me the 404 error, but instead correctly loads!!! Thanks!
@ismailuddin Thanks a million! It does work on http://localhost:8501/index.html 
> I've been able to get it to work while running JupyterLab by simply navigating to http://localhost:8501/index.html and then the page loads

Awesome, @ismailuddin !! Thanks for the work-around.

I'm still having problems reproducing the issue, though. So I have some more questions:
1. Did a previous version of Streamlit ever work? If so, can you downgrade and confirm? (When doing this, use `streamlit version` to double-check which version you're on)
2. Can you send me a HAR file for what happens when you go to `localhost:8501/` and when you go to `localhost:8501/index.html`?

Here's a page talking about how to grab a HAR file in different browsers: https://community.box.com/t5/Managing-Content-Troubleshooting/How-to-Generate-Network-Captures-for-Troubleshooting/ta-p/366

---
> Note that you can't run jupyter-lab and streamlit at the same time, since they both by default use the same port; 

Weird. On my machine, JupyterLab uses 8888 while Streamlit uses 8501. Are you saying they're both on 8501 on your machine?

Also, since version 0.47.0 Streamlit tries to find an open port when 8501 is taken. So even if JupyterLab is on that port Streamlit should run fine.

~Edit: I just realized the port-finder code isn't working on Python 2. We have a fix and will have it out with the next release.~ This is fixed since 0.47.4
Thank you @ismailuddin 
Yup on my machine Jupyter Lab is using port 8888 as well so it shouldn't actually be interfering. Tbh, I didn't actually try without JLab since it's practically always running on my laptop. Unfortunately I don't have access to my Windows machine for a few days so won't be able to try any of that out just yet. 
Sorry Jupyter Lab is using port 8888 on my machine.
Thanks, that makes sense! So I'm assuming the JupyterLab thing is a red herring at this point.

My best guess is that this would be fixed if we modified [this function call](https://github.com/streamlit/streamlit/blob/develop/lib/streamlit/server/Server.py#L236) in `streamlit/server/Server.py` to this:

```python
            routes.extend(
                [
                    (r"/(.*)", StaticFileHandler, {
                        "path": "%s/" % static_path,
                        "default_filename": "index.html",
                    }),
                ]
            )
```

But I can't repro the issue, so I can't verify that this fixes it. (Although we should probably do this anyway since it's cleaner than the current code!)

That said, if any enterprising soul would like verify that the above solves your problem, that would be amazing :smiley: 
That change fixes the issue for me.

Resolving patch:
diff --git a/lib/streamlit/DeltaGenerator.py b/lib/streamlit/DeltaGenerator.py
--- a/lib/streamlit/DeltaGenerator.py
+++ b/lib/streamlit/DeltaGenerator.py
@@ -2030,8 +2030,10 @@ def deck_gl_chart(self, element, spec=None, **kwargs):
                   The data for the current layer.
 
                 - "type" : str
-                  A layer type accepted by Deck.GL, such as "HexagonLayer",
-                  "ScatterplotLayer", "TextLayer"
+                  One of the Deck.GL layer types that are currently supported
+                  by Streamlit: ArcLayer, GridLayer, HexagonLayer, LineLayer,
+                  PointCloudLayer, ScatterplotLayer, ScreenGridLayer,
+                  TextLayer.
 
                 - "encoding" : dict
                   A mapping connecting specific fields in the dataset to
diff --git a/lib/streamlit/server/Server.py b/lib/streamlit/server/Server.py
--- a/lib/streamlit/server/Server.py
+++ b/lib/streamlit/server/Server.py
@@ -247,12 +247,10 @@ def _create_app(self):
 
             routes.extend(
                 [
-                    (
-                        r"/()$",
-                        StaticFileHandler,
-                        {"path": "%s/index.html" % static_path},
-                    ),
-                    (r"/(.*)", StaticFileHandler, {"path": "%s/" % static_path}),
+                    (r"/(.*)", StaticFileHandler, {
+                        "path": "%s/" % static_path,
+                        "default_filename": "index.html",
+                    }),
                 ]
             )
 
diff --git a/lib/streamlit/util.py b/lib/streamlit/util.py
--- a/lib/streamlit/util.py
+++ b/lib/streamlit/util.py
@@ -245,26 +245,25 @@ def open_browser(url):
 
     system = platform.system()
 
+    if system == "Windows":
+        # Treat Windows separately because:
+        # 1. /dev/null doesn't exist.
+        # 2. subprocess.Popen(['start', url]) doesn't actually pop up the
+        #    browser even though 'start url' works from the command prompt.
+        # Fun!
+        import webbrowser
+        webbrowser.open(url)
+        return
+
+    # We don't use the webbrowser module on Linux and Mac because some browsers
+    # (ahem... Chrome) always print "Opening in existing browser session" to
+    # the terminal, which is spammy and annoying. So instead we start the
+    # browser ourselves and send all its output to /dev/null.
+
     if system == "Linux":
         cmd = ["xdg-open", url]
     elif system == "Darwin":
         cmd = ["open", url]
-    elif system == "Windows":
-        # Windows has a few bugs.
-        # * os.devnull doesnt exist so the open command below fails
-        # * subprocess doesnt actually pop up the browser even though
-        #   'start url' works from the command prompt
-        # * tornado for whatever reason doesnt map / to /index.html and
-        #   you get a 404.
-        data = urllib.parse.urlsplit(url)
-        (scheme, netloc, path, query, fragment) = data
-        if re.match(r"^/$", path):
-            path = "/index.html"
-        url = urllib.parse.urlunsplit((scheme, netloc, path, query, fragment))
-        import webbrowser
-
-        webbrowser.open(url)
-        return
     else:
         raise Error('Cannot open browser in platform "%s"' % system)
 


Test patch: