--- app.js.bak 2017-03-15 02:31:40.749999989 +0000
+++ app.js 2017-03-15 02:32:42.653333318 +0000
@@ -8,6 +8,7 @@
var index = require('./routes/index');
var users = require('./routes/users');
+var apis = require('./routes/apis');
var app = express();
@@ -31,6 +32,7 @@
app.use('/', index);
app.use('/users', users);
+app.use('/apis', apis);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
Edit users.js under routes
When user get info from “users”, “users” will send back info to webpage.
So use “router.get”.
--- users.js.bak 2017-03-15 02:31:34.113333328 +0000
+++ users.js 2017-03-15 02:32:00.576666660 +0000
@@ -1,9 +1,44 @@
var express = require('express');
var router = express.Router();
-/* GET users listing. */
-router.get('/', function(req, res, next) {
- res.send('respond with a resource');
+/* 使用者註冊頁面. */
+router.get('/register', function(req, res, next) {
+ res.send("This is the register page.");
+});
+
+/* 使用者登入頁面. */
+router.get('/signin', function(req, res, next) {
+ res.send("This is the signin page.");
+});
+
+/* 使用者登出頁面. */
+router.get('/signout', function(req, res, next) {
+ res.send("This is the signout page.");
+});
+
+/* 忘記密碼頁面. */
+router.get('/forget', function(req, res, next) {
+ res.send("This is the forget page.");
+});
+
+/* 使用者管理頁面. */
+router.get('/profile', function(req, res, next) {
+ res.send("This is the profile page.");
+});
+
+/* 新增文章頁面. */
+router.get('/add_article', function(req, res, next) {
+ res.send("This is the add_article page.");
+});
+
+/* 修改文章頁面. */
+router.get('/modify/:id', function(req, res, next) {
+ res.send("This is the modify page.");
+});
+
+/* 訪客留言頁面. */
+router.get('/message/:id', function(req, res, next) {
+ res.send("This is the message page.");
});
module.exports = router;
User will input some info, so use “router.post”.var express = require('express');
var router = express.Router();
/* 使用者刪除文章功能. */
router.get('/delete/:id', function(req, res, next) {
res.send("This is the delete function.");
});
/* 使用者登入會員功能. */
router.post('/login', function(req, res, next) {
res.send("This is the login function.");
});
/* 使用者新增文章功能. */
router.post('/add', function(req, res, next) {
res.send("This is the add function.");
});
/* 使用者更新文章功能. */
router.post('/update/:id', function(req, res, next) {
res.send("This is the update function.");
});
/* 文章留言功能. */
router.post('/comment/:id', function(req, res, next) {
res.send("This is the comment function.");
});
module.exports = router;
0 意見:
張貼留言