planety / prologue-examples

A repository to host examples for Prologue framework written in Nim language.
Apache License 2.0
31 stars 6 forks source link

HelloWorld example does not compile #6

Closed inviridi closed 1 year ago

inviridi commented 1 year ago

Hi team prologue,

I have a few years of Python under my beld but am new to Nim. I was amazed by the numer of examples and look forward to working with Prologue! Yet the basic helloworld example does not compile with the latest versions of Nim and Prologue (via choosenim). The error I get is:

Error: unhandled exception: key not found: staticDir [KeyError]

but the compiler does not tell me in which variable the key is missing. The same happens when I copy and paste from the docs ("serve static files").

import prologue
import prologue/middlewares/staticfile

var app = newApp(settings = settings)
app.use(staticFileMiddleware(env.get("staticDir")))
# add your routes
app.run()

Is there something wrong with my setup or do I miss something. Anyway. I filed this issue, because the examples should run "as-is", right?

Thanks for your hard work and have a nice day!

Cheers, Frank

ringabout commented 1 year ago

@inviridi hello, which example you are referring to? Did you add a .env file like https://github.com/planety/prologue-examples/blob/master/blog/.env?

inviridi commented 1 year ago

Hi @ringabout, I tried to run the "Hello World" example and do not have a .env file. But I can see now, why you ask this:

let env = loadPrologueEnv(".env")

and indeed, there is no such mapping. When I add the last line to .env to make it look like this:

# Don't commit this to source control.
# Eg. Make sure ".env" in your ".gitignore" file.
# If you want to release you programs, make sure set debug=false.
debug=true
port=8080
appName=nimstack
secretKey=Pr435ol67ogue
staticDir=/static

I get the same error though.

ringabout commented 1 year ago

Do you mean this one? https://github.com/planety/prologue-examples/blob/master/helloworld/app.nim

It works for me.

git clone https://github.com/planety/prologue-examples
cd prologue-examples/helloworld
nim c -r app.nim

Prologue version 0.6.2

inviridi commented 1 year ago

While being slightly embarrassed, I also happyly confirm that your example indeed works as expected. No idea, where things went wrong... but thanks a lot for your time!