Skip to content

Instantly share code, notes, and snippets.

@techwraith
Created November 30, 2012 22:01
Show Gist options
  • Save techwraith/4179006 to your computer and use it in GitHub Desktop.
Save techwraith/4179006 to your computer and use it in GitHub Desktop.
Redirect example
var Main = function () {
this.index = function (req, resp, params) {
if (this.session.get('test')) {
params.test = this.session.get('test');
} else {
params.test = null;
}
this.respond(params, {
format: 'html'
, template: 'app/views/main/index'
});
};
this.handleCommand = function (req, resp, params) {
var self = this;
setTimeout(function() {
self.session.set('test', params.test);
self.redirect('/');
}, 10);
};
};
exports.Main = Main;
var router = new geddy.RegExpRouter();
router.get('/').to('Main.index');
router.post('/').to('Main.handleCommand');
exports.router = router;
<div class="hero-unit geddy-welcome-box">
<h1>Enter a command:</h1>
<form action="/" method="POST">
<input type="text" name="test" id="test"/>
<input type="submit" value="execute"/>
</form>
<% if (test) { %>
<h2>Result:</h2>
<p><%= test %></p>
<% } %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment