예제 #1
0
파일: app.py 프로젝트: ajlopez/JPyScript
app.use(express.cookieParser('your secret here'))
app.use(express.session())
app.use(app.router)
app.use(express.static('./public'))

# development only
if 'development' == app.get('env'):
    app.use(express.errorHandler())
    
def index(request, response):
    response.render('index', { 'title': 'My Business' })

def about(request, response):
    response.render('index', { 'title': 'About' })

def contact(request, response):
    response.render('index', { 'title': 'Contact' })

app.get('/', index)
app.get('/about', about)
app.get('/customer', customer.index)
app.get('/customer/:id', customer.view)
app.get('/contact', contact)

def started():
    console.log('Express server listening on port ' + app.get('port'))

server = http.createServer(app)
server.listen(app.get('port'), started)

예제 #2
0
import http

def say_hello(request, response):
    response.end("<h1>Hello, world</h1>")

server = http.createServer(say_hello)

server.listen(3000)