Integrated Application Platform › Forums › General › Razor › Reply To: Razor
August 13, 2019 at 1:41 pm
#1477
Participant
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.