Yuristiawan
Yuristiawan

Reputation: 13

How to show dynamic image with server side vapor swift?

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.

Upvotes: 1

Views: 908

Answers (1)

Genki
Genki

Reputation: 3195

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)">

Upvotes: 7

Related Questions