Alright, so I know that I can configure a default ...
# ktor
r
Alright, so I know that I can configure a default file to serve in a static block, but how can I serve a static file from the structure I've set in that static block for one request?
o
Not sure I understand. Can you give an example?
r
I found a way to do it, though I feel there's a better way.
Basically, I have a react app that gets served at /, and there's some data to be filled out that will eventually be POSTed serverside
When that happens, I want to send back a static html file saying that the request has been processed, and that just has some javascript to send them back to the root of the app after a couple of seconds
I just ended up doing this
call.respond(File(staticFolder, "success.html").readText())
o
Hmm, why would you send html page in response to a React app POST request? I imagine you’d send a JSON back with data needed to render the message, and then React app would do the rest?
Also,
readText
from file is blocking call. Better to respond with LocalFileContent
I think we might need
call.respondFile(baseDir, file)
r
Regardless of the poor architecture choices on my part, I thing that'd be a good addition
o
Added
👍 1