Last active
August 29, 2015 13:56
-
-
Save adamhalasz/9020056 to your computer and use it in GitHub Desktop.
Hello world in Diet v0.3.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Call Diet | |
var Application = require('diet'); | |
// Initalize Application | |
app = new Application.setup({ | |
'domain' : 'example.com', // default is localhost (127.0.0.1) | |
'port' : 80, // default is 80 | |
'path' : __dirname, // required path to this folder __dirname is ok | |
'public' : __dirname +'/resources', // required path to the app resources (images etc..) | |
'header' : init, // function that runs when the server loaded completly (mysql etc...) | |
'mysql' : { // optional if you need a database | |
'host' : 'example_host' // usually localhost (127.0.0.1) | |
'user' : 'example_username', // the username accesing mysql (usually root) | |
'password' : 'example_password' // the password for username | |
'database' : 'example_database' // the default database to work with | |
} | |
}); | |
// When every asynchronous configuration finished loading | |
// Do not use app.ready() if mysql is not specified in the setup | |
// Just simply use code after app is defined. | |
app.ready(function(){ | |
// Listen on http://example.com/ | |
app.get('/', function(request, response, mysql){ | |
response.end('hello world!'); | |
mysql.end(); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment