Serve static file index.html

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Serve static file index.html

Jorge
Hello!

Trying to serve a static file index.html, not a template, when accessing http://localhost:5050/, but failing. Any tip please?

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Serve static file index.html

tomaslin
Make sure you have

assets 'public'

within your handlers and then put the index.html file in your public folder.

see https://github.com/robfletcher/midcentury-ipsum/blob/master/src/ratpack/ratpack.groovy for an example.
Reply | Threaded
Open this post in threaded view
|

Re: Serve static file index.html

Jorge
Thank you, so fast :)

With assets "public" can access http://localhost:5050/index.html

But have tryed http://localhost:5050, return the file with:

get {
    //render 'index.html'
    //....
    //And only works with
    response.contentType('text/html').send new File("public/index.html").text
}

Any tip?
Reply | Threaded
Open this post in threaded view
|

Re: Serve static file index.html

tomaslin
Add a file called ratpack.properties and define the index patterns there

https://github.com/ratpack/ratpack/blob/master/ratpack-site/src/ratpack/ratpack.properties
Reply | Threaded
Open this post in threaded view
|

Re: Serve static file index.html

Jorge
\o/ Thank you very much