Skip to content

Instantly share code, notes, and snippets.

@evanxg852000
Created November 22, 2018 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanxg852000/dc16792c3ae2c19570cc032809acf593 to your computer and use it in GitHub Desktop.
Save evanxg852000/dc16792c3ae2c19570cc032809acf593 to your computer and use it in GitHub Desktop.
const Micro = require('./micro')
const app = new Micro({
env: 'prod',
templates: './templates',
port: 3535
})
app.router.all('/', (req, res) => {
res.end('Micro ...')
})
app.route((router) => {
router.get('/template', (req, res) => {
let data = {title: 'Home', test:true, items: ['Evan', 'John', 'Jane']}
res.render('index.html', data)
})
router.all('/hello/:name?', (req, res) => {
let name = req.params['name'] || 'world'
res.end(`Hello ${name}!`)
})
})
app.boot((err) => {
console.log('OK');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment