<div dir="ltr"><div dir="ltr">On Fri, Sep 11, 2020 at 1:15 PM Daniel Kozak <<a href="mailto:kozzi11@gmail.com">kozzi11@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Sep 11, 2020 at 1:10 PM Selim Ozel via Digitalmars-d-learn <<a href="mailto:digitalmars-d-learn@puremagic.com" target="_blank">digitalmars-d-learn@puremagic.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It seems like rejected-software forum is flooded with spam, so I <br>
decided to ask it here. Is there a way to generate a file -csv <br>
for example- on the back-end and serve it to the front-end as a <br>
file.<br>
<br>
Serve static file [1] function does this for files saved on the <br>
disk. I want to be able to generate a file during runtime and <br>
serve it to the client. Is this possible?<br>
<br>
Thanks,<br>
S<br>
<br>
<br>
[1] <a href="https://vibed.org/api/vibe.http.fileserver/serveStaticFile" rel="noreferrer" target="_blank">https://vibed.org/api/vibe.http.fileserver/serveStaticFile</a><br>
<br>
<br></blockquote><div><br></div><div><a href="https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody" target="_blank">https://vibed.org/api/vibe.http.server/HTTPServerResponse.writeBody</a> </div></div></div></blockquote><div><br></div>import vibe.core.core;<br>import vibe.http.server;<br><br><br>void main()<br>{<br>  runWorkerTaskDist(&wrap);<br>    runApplication();<br>}<br><br>void wrap()<br>{<br>   auto settings = new HTTPServerSettings(":8080");<br>    settings.options |= HTTPServerOption.reusePort;<br>       listenHTTP(settings, &fun);<br>}<br><br>void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow<br>{<br>      try<br>   {<br>             res.headers["Content-Disposition"] = "filename=\"muj.csv\"";<br>            res.writeBody("some;csv;data", "text/csv");<br>       }<br>     catch (Exception e)<br>   {}<br><div>} </div></div></div>