dom96 / jester

A sinatra-like web framework for Nim.
MIT License
1.56k stars 120 forks source link

static folder not working #322

Closed AritraBanik08 closed 6 months ago

AritraBanik08 commented 10 months ago

I am creating the links shown in this example here. Can anyone help me with this?

AritraBanik08 commented 10 months ago

can anyone tell me why the static files in the folder public are not working?

ThomasTJdev commented 10 months ago

Hi @AritraBanik08

If you use the basic routing, then it's straight forward like this:

settings:
  staticDir = "tests/public"

routes:
  get "/":
    resp "Hello World"

And then ensure your are in the parent directory to tests/public. Files located in the public will then be fetched directly, like: curl 127.0.0.1:5000/tests/public/test.txt.

If you are using the method from example2.nim, then you need to dive into jesters code to ensure, that the handler for static-dir matching is used. Your code example only "approves" two routes - which does not include the static-dir.

AritraBanik08 commented 10 months ago

Hello @ThomasTJdev can you please help me to do it along with the method shown in example2.nim. Thank you for your help