博客
关于我
Express路由是如何实现的?
阅读量:208 次
发布时间:2019-02-28

本文共 1069 字,大约阅读时间需要 3 分钟。

Express??????Node.js??????????????????????????Express?????HTTP????????????????URL???????????

Express????????URL????????????????????????????????Express????????

  • ???????

    Express??res.send()???HTTP?????????????????????????????????app??????URL????????????????????????????GET/POST???????????

  • ????

    Express???app.get()?app.post()????????????????????????????????????????/????????????

  • ????

    ???????????????????????????????????????????no router?????POST???Express???????????????????req.body??????????

  • ???????Express??????

    const http = require('http');const ejs = require('ejs');const app = require('express-route');http.createServer(app).listen(3000);// ????app.get('/', (req, res) => {    const msg = '????????';    ejs.renderFile('views/index.ejs', { msg }, (err, data) => {        res.send(data);    });});// ??????app.get('/login', (req, res) => {    ejs.renderFile('views/form.ejs', {}, (err, data) => {        res.send(data);    });});// ??????app.post('/dologin', (req, res) => {    console.log(req.body);    res.send("");});

    ???????????Express??????????????????????HTTP???

    转载地址:http://hgip.baihongyu.com/

    你可能感兴趣的文章
    Python - 安装了扩展的远程 Webdriver
    查看>>
    python - 将字符串中的日期与今天的日期进行比较
    查看>>
    python - 数据描述符(class 内置 get/set/delete方法 )
    查看>>
    Python - 根据值绘制彩色网格
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 正则表达式在括号之间获取数字
    查看>>
    Python - 类 __hash__ 方法和集合
    查看>>
    Python - 轻松将文本文件内容转换为字典值/键
    查看>>
    Python - 递归和列表
    查看>>
    python -- 小数据池 is和 == 再谈编码
    查看>>
    Python -- 算法实现
    查看>>
    python --- 元组(tuple)
    查看>>
    python --- 列表(list)
    查看>>
    python --- 协程
    查看>>
    python --- 字符串 str
    查看>>
    python ----元组方法以及修改细节
    查看>>
    python ----字典dict
    查看>>
    python / 解决 pyinstaller 打包后运行时提示找不到模块的问题
    查看>>
    Python 10 个习惯用法,短平快第一期
    查看>>