webui-dev / nim-webui

Use any web browser as GUI, with Nim in the backend and HTML5 in the frontend.
https://webui.me
MIT License
130 stars 9 forks source link

Crash webui@#main #37

Closed Sznymo closed 1 month ago

Sznymo commented 1 month ago

The latest version of webui installed by " nimble install webui@#main", shuts down after a few seconds giving something like this in the console zrzut_ekranu_20240714_003635

Sznymo commented 1 month ago

Ok I already see where the error is after moving to heat from the end of the page, the code does not crash . But I have a question, in the old version I could use the files in the folder. in the new version I can not. how to fix it ?

hassandraga commented 1 month ago

you need to set the root path of the folder, so WebUI will look for requested HTTP files in that folder.

Sznymo commented 1 month ago

I already did it thank you :) , but it makes me wonder why the older version didn't need to be set up

window.setFileHandler() do (filename: string) -> string:
  var config: JsonNode = fromJson(readFile("""config.json"""))
  var lang: JsonNode = parseJson(readFile(getCurrentDir() / "data" / "lang" / config["language"].getstr & ".json"))
  case filename
  of "/installed_mods.html":
    return site(installed_mods(lang))
  of "/index.html":
    return site(index(lang))
  of "/options.html":
    return site(options(lang))
  of "/version_game.html":
    return site(version_game(lang,"stable"))
  of "/online_mods_list.html":
    return site(online_mods_list(lang))
  of "/filebrowsersite.html":
    return site(filebrowsersite(lang,config["game_dir"].getstr),false)
  of "/setup_wizard.html":
    return site(setup_wizard(lang),false)
  else:
    if fileExists(getCurrentDir() / filename):
      return readFile(getCurrentDir() / filename)