- This topic has 4 replies, 3 voices, and was last updated 4 years, 1 month ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.
Integrated Application Platform
Integrated Application Platform › Forums › General › Razor
Hi,
Would be possible to show me a sample code with razor and RackServer please.
Have a nice day and thank you for your reply.
Regards
Joshob
Our applications are large but I’ll see if I can come up with a small example.
Thanks for your reply.
All I want to know is how I can query a database and display the result with RackServer and Razor.
Have a nice day !
joshob
Here is a simple Rack server listing all the database table names
class
{
CallClass(port = 80)
{
RackServer(app: RackRouter(.routes()), with: [RackLog], :port)
}
routes()
{
return [['GET', '/tables$', .tables]]
}
tables(env/*unused*/)
{
content = QueryList("tables", 'tablename')
return Razor(.template, [:content])
}
template: '
<html>
<head lang="en"><meta charset="UTF-8"></head>
<body>
<h1>Tables</h1>
@for(line in .content)
{
<div>@line</div>
}
</body>
</html>'
}
To start the server, you just need to call the class name of this code in workspace. After launching the server, you can visit “http://127.0.0.1/tables” to see the page.
hao_xie
Thank you very much for your code. It’ll be useful and I’ll can learn from it.
Regards,
Joshob