Another noob question: blank page when opening html file on localhost

3,971 views
Skip to first unread message

Bernd Blasius

unread,
Sep 13, 2013, 4:54:55 PM9/13/13
to elm-d...@googlegroups.com
I get a blank screen when I open elm-generated htlm files on localhost.

Take a simple Elm program, such as

Module Test where
main = plainText "Hello"

Generate htlm.code with "elm --make Test.elm", which generates the file Test.html in the folder build.

When I open the file directly in my browser as file:///path_to_build/Test.elm I get my nice greeting in the browser.
If I run elm-server, and open http://localhost:8000/Test.elm this works fine again.
However, when I open the file under localhost as http://localhost/path_to_build/Test.html I just get a white blank screen.
I get a similar blank screen when I serve the html-file with a standard LAMP server and open the page from a remote computer. 

I'm using Elm 0.9.0.2 under Ubuntu. I find the same problem in different browsers and different Ubuntu versions.



Dobes Vandermeer

unread,
Sep 13, 2013, 5:20:49 PM9/13/13
to elm-d...@googlegroups.com
Maybe you can take a look at your firebug / chrome dev tools console and see if there are any errors in there, either in network communications or javascript.  That might give a clue.



--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Evan Czaplicki

unread,
Sep 13, 2013, 5:42:59 PM9/13/13
to elm-d...@googlegroups.com
First, why are you doing this? Opening the Test.elm path is actually showing you the .html file in your build directory. From there, two things may be happening:
  1. You are trying to use a port that does not exist. In the broken link, you are accessing localhost:80, which elm-server does not respond to.
  2. The Test.html links to a file on your system, but the browser asks elm-server for it. This could lead to some weird file path conflicts.
Showing the console error will give more insight.

Evan Czaplicki

unread,
Sep 13, 2013, 5:44:03 PM9/13/13
to elm-d...@googlegroups.com
Also, that first sentence sounded harsh. I'm not saying it's wrong or bad or anything, I'm just curious why you wanted to look at that.

Dobes Vandermeer

unread,
Sep 13, 2013, 6:09:58 PM9/13/13
to elm-d...@googlegroups.com
Evan,

It sounds like he's just trying to see if the script works outside the elm-server or filesystem URLs.  The port is different because it's for his own little apache setup.


On Fri, Sep 13, 2013 at 2:42 PM, Evan Czaplicki <eva...@gmail.com> wrote:

Evan Czaplicki

unread,
Sep 13, 2013, 6:28:43 PM9/13/13
to elm-d...@googlegroups.com
Ohhhh, okay. Sorry :) It may be something with the --runtime flag then.

Dobes Vandermeer

unread,
Sep 13, 2013, 6:33:44 PM9/13/13
to elm-d...@googlegroups.com
Ah yes, good point.  

Bernd: Sometimes the --runtime flag means the "src" of the script for the runtime is wrong when you try to load the file from a web server.  Take a look at that and see if it's relative or absolute.

Bernd Blasius

unread,
Sep 14, 2013, 12:00:51 PM9/14/13
to elm-d...@googlegroups.com
Thanks, it was really the runtime.
The path for the elm-runtime in Test.htlm was absolute, but maybe my server for some reasons has no access to my .cabal directory.
I now have placed a copy of elm-runtime.js into my build directory and compile with the -r flag, and it works fine :-)

Evan: It is as Dobes has guesses. I want to build a small interactive web-page with Elm and want to serve it with an already set-up Apache server. 
I have no clue how to use elm-server for this, but avoid that the URL of my page contains :8000 (sorry, I'm more in programming than in system administration).

Thanks for the fast answer!

Alex Neslusan

unread,
Sep 14, 2013, 1:21:28 PM9/14/13
to elm-d...@googlegroups.com
I'm guessing you're using Windows. Windows file linking is a bit different, you need a file:/// prefix. For example, when I'm on my Windows 7 computer, and I type "elm Test.elm", it generates the Test.html file in /build. If I open Test.html in my text editor, I can see this line near the top:

<script type="text/javascript" src="C:\Users\Alex\AppData\Roaming\cabal\Elm-0.9.0.2\elm-runtime.js">

Which would be fine on Linux, but on Windows you need that prefix file:///, so if you manually edit the .html file to:

<script type="text/javascript" src="file:///C:\Users\Alex\AppData\Roaming\cabal\Elm-0.9.0.2\elm-runtime.js">

then it will work. The best way to do it on windows is to either manually copy the elm-runtime.js file into /build and compile with the --runtime flag like: "elm --runtime=elm-runtime.js Test.elm" OR to figure out your absolute runtime path by compiling 1 file then passing that plus file:/// to the --runtime flag: "elm --runtime=file:///C:\Users\Alex\AppData\Roaming\cabal\Elm-0.9.0.2\elm-runtime.js Test.elm"

I've just set up a build configuration in Sublime Text to automatically do the absolute path with file:/// prepended whenever I press ctrl+b

Alex Neslusan

unread,
Sep 14, 2013, 1:22:25 PM9/14/13
to elm-d...@googlegroups.com
Oh, or I'm being dumb and you clearly said Ubuntu

pcarbonn

unread,
May 31, 2016, 4:10:37 PM5/31/16
to Elm Discuss
Hi all,

I have a similar problem as Bernd Blasius, on Windows, and I found this old thread below while searching for a solution : could someone help me ?  I have posted my full problem on StackOverflow.  You can find all details there.  It's my first elm program, so any help would be appreciated !

Thanks in advance,
PC

pcarbonn

unread,
May 31, 2016, 4:21:48 PM5/31/16
to Elm Discuss
OK. I finally fixed it by deleting the elm-stuff subdirectory...  At the next make, it reinstalled the missing packages, and it worked fine.
Reply all
Reply to author
Forward
0 new messages