HapticX / happyx

Macro-oriented asynchronous web-framework written in Nim with ♥
https://hapticx.github.io/happyx/
MIT License
540 stars 18 forks source link

Lacking documentation for the `public` directory #50

Closed PMunch closed 1 year ago

PMunch commented 1 year ago

Tried to use HappyX today but I'm a bit confused. Basically I just wanted to try out a very simple SSG with some static HTML/CSS files and a route to catch the input from a form. I created my project using hpx create --name test --kind SSG and it created the project structure for me. I dropped some files into the public folder but the server doesn't seem to serve these files. Looked at the examples and the only one which appears to do this is the nim-lang one and it appears to serve them with the public prefix on, however trying that didn't make it serve my file either. So I'm not sure if I need to do something to make HappyX serve the files from the public directory or not, it doesn't log requests either so I don't really know what's going on..

This was tested with the latest tagged version of HappyX (which is the 1.0.0 release) The project structure is simply the one created by hpx create --name test --kind SSG with an additional file added in the src/public folder. The code is exactly what was generated. I looked at the nim-lang site example which has a public folder but couldn't see any special handling of it.

Ethosa commented 1 year ago

https://hapticx.github.io/happyx/happyx/ssr/server.html#server-%F0%9F%94%A8-static-directories-%F0%9F%8D%8D

Ethosa commented 1 year ago

You just should use this for SSR/SSG projects

serve(....):
  ...
  staticDir "public"

or

serve(....):
  ...
  staticDir "/route" -> "public"
lorenzncode commented 7 months ago

it doesn't log requests either

Trying happyx today and stumbled on this as well. Compiling with -d:debug will log requests.

[2024-04-05 at 22:37:29]:INFO GET::/route/mypage.html
[2024-04-05 at 22:37:29]:INFO GET::/favicon.ico
[2024-04-05 at 22:38:11]:INFO GET::/route/badpath
[2024-04-05 at 22:38:11]:WARN /route/badpath is not found.

(the above with: staticDir "/route" -> "public")

Also the public dir should be relative to working dir where nim is invoked.

Ethosa commented 7 months ago

what version are you use? @lorenzncode

lorenzncode commented 7 months ago

3.8.1 (installed with atlas). FYI staticDir is working for me now. I don't have an issue now.

Ethosa commented 7 months ago

Please install latest version - 3.8.14