Disclaimer: This is not a real tutorial document.
Silver Bullet is a general-purpose programming language, which has some specific features for web development like PHP, but doesn't suck.
$ wget http://silverbullet.org/install.sh - | sudo sh $ echo "return 'Hello!'" > test.sb $ sb test.sb & Running test.sb at http://127.0.0.1:8080/ $ curl http://127.0.0.1:8080/ Hello!
The simplest form of Silver Bullet application is just returning the content to respond.
return 'Hello!'
This application will generate 200 OK response containing the text "Hello!" in text/html content type.
You can also specify return code and content type by explicitly creating a Response object. The first argument is status code, the second is the content, the third is a dictionary of HTTP headers.
return Response(Response.OK, 'Hello!', {Content-Type: 'text/html'})
Response class has some convenience methods, for example, redirect.
return Response.redirect('http://www.google.com/')
Most web applications use URL to distinguish which content users want. By defining multiple sub-applications, Silver Bullet server will parse the requested URL and distribute the request into them.
def a @ /a { return 'a' }
def b @ /b { return 'b' }
In the above example, requesting /a will respond with 'a', /b will respond with 'b'.
You can also get parameters from URL. By default, parameters are in string type.
def hello @ /hello/<name> { return name }