0

I recently took an interest in Dart, and followed their tutorial pirate badge. After completion, I built it and uploaded to my webserver. In the start of the app, it calls a .json file:

static Future readyThePirates() {
    var path = 'piratenames.json';
    return HttpRequest.getString(path).then(_parsePirateNamesFromJSON);
}

void main() {
    //... other code
    PirateName.readyThePirates()
        .then((_) {
            inputField.disabled = false;
            genButton.disabled = false;
            setBadgeName(getBadgeNameFromStorage());
         })
        .catchError((arrr){
            print('Error initializing pirate names: $arrr');
            badgeNameElement.text = 'Arrr! No names.';
         });
    }
    //... more code
}

Here is a screen of my FTP:

ftp

Obviously the file is there, but when I load it up in a browser I get an error. Inspecting in Chrome I get this:

debug

It works just fine when I run it in Dartium (from the Dart editor), not sure why it is having an issue on a live page.

Anyone know what might be going on?

Anders
  • 12,088
  • 34
  • 98
  • 146
  • What is the actual URL for the JSON file on your server? – Günter Zöchbauer May 19 '14 at 17:29
  • Could it be that your files are not in the recommended locations, and that `pub`, because of this, doesn't copy the necessary files into the build-directory? It looks like your files are in the top-level of the project instead of in a directory `bin` or `lib`. – Florian Loitsch May 19 '14 at 20:13
  • Well, depending on what he's showing in the screenshot, we could be looking at `web/`, which should work. @Anders can you give more context? – Justin Fagnani May 19 '14 at 22:41
  • I ran the compiler inside of the Dart IDE, and what you see on the FTP is exactly what it gave inside the publish folder, `pub` I believe. – Anders May 20 '14 at 07:11
  • All of these file are in the `/pirate/` directory on the server. It is the root folder of the application. – Anders May 20 '14 at 07:12

1 Answers1

2

Are you using IIS?

I recently discovered IIS would serve up 404s for any file extension it didn't know the mime type for; so my .sqlite files were showing 404s when I could see them on disk!

You can fix it in the IIS management interface, which basically just edits your web.config, inserting something like this:

<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension="json" mimeType="text/plain" />
    </staticContent>
  </system.webServer>
</configuration> 
Community
  • 1
  • 1
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275