1

i just newbie and want learn more about server side swift with vapor, now i am really stack on the show image dynamically with vapor swift. in my case. i have image on folder :

public -> images -> a.png , b.png

and i have name of image on my database, and i want to make get requests for show image on leaf file, with parameter name of my image, how to implement thats. Thanks a lot.

1 Answers1

7

You can create route like so:

drop.get("route") { request in
    return try self.drop.view.make("path/to/somepage", ["myimage": "/images/a.png"])
}

And in your somepage.leaf:

<img src="#(myimage)">
Genki
  • 3,055
  • 2
  • 29
  • 42
  • @Gomfucius, i have written this code but i got error. Is it write? drop.get("route") { request in return try drop.view.make("http://localhost:8080/", ["myimage": "/CSImages/GumoStyleM15.png"]) } –  Dmitriy Greh Dec 10 '17 at 07:59