# entry **Repository Path**: huafua/entry ## Basic Information - **Project Name**: entry - **Description**: 供應商管理平台統一入口,樣例 - **Primary Language**: NodeJS - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-10-29 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 1.1 创建npm项目 ``` shell npm init ``` ## 1.2 创建入口app.js ``` shell touch app.js ``` ## 1.3 安装依赖 ```shell npm install express ejs nodemon ``` ## 1.5 修改package.json ``` javascript { "scripts":{ "test":"nodemon app" } } ``` ## 1.6 创建静态文件夹及模板文件夹 ```shell mkdir www mkdir views ``` ## 1.7 编写app.js文件代码 ``` javascript const express=require("express"); var app=express(); app.set("view engine","ejs"); app.set("views","./views"); app.use("/index",function(req,res){ res.render("index"); }); app.use("/login",function(req,res){ res.render("login"); }); app.use("/static",express.static("./www")); app.use("/",function(req,res){ res.redirect("/login"); }); app.listen(8080,function(){ console.log("Server started at 8080..."); }); ``` ## 1.8 运行测试 ```shell npm test ``` 尝试运行一下,浏览器中输入`http://localhost:8080`,效果如下: - 用户登录 ![用户登录](./readme-static/login.png) - 用户首页 ![用户首页](./readme-static/home.png) - 系统清单 ![系统清单](./readme-static/list.png) ## THE END! 你可以到[https://huafua.github.io](https://huafua.github.io)看看效果