首页 > 代码库 > express再学习
express再学习
对比spring,django,再学习express就有很多共通的地方啦。。。
看的书是一本小书,《express in action》,排版比较好。
昨天开始看,看了快四分之一啦。。。
练习代码:
var express = require("express");var http = require("http");var path = require("path");var logger = require("morgan");var app = express();var publicPath = path.resolve(__dirname, "public");app.set("views", path.resolve(__dirname, "views"));app.set("view engine", "ejs");app.use(express.static(publicPath));app.use(logger("short"));app.get("/", function(request, response) { response.render("index", { message: "Hey everyone! This is my webpage." });});app.get("/about", function(request, response) { response.end("Welcome to my aboutpage!");});app.get("/weather", function(request, response) { response.end("The current weather is NICE!");});app.get("/user/:who", function(request, response) { response.end("Hello, " + request.params.who + ".");});app.use(function(request, response) { response.statusCode = 404; response.end("404!");});http.createServer(app).listen(3000);
express再学习
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。