博客
关于我
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/

    你可能感兴趣的文章
    regExp的match、exec、test区别
    查看>>
    php 404 自定义,APACHE 自定义404错误页面设置方法
    查看>>
    PHP 5.3.0以上推荐使用mysqlnd驱动
    查看>>
    php 7.2 安装 mcrypt 扩展: mcrypt 扩展从 php 7.1.0 开始废弃;自 php 7.2.0 起,会移到 pecl...
    查看>>
    php aes sha1解密,PHP AES加密/解密
    查看>>
    php array 分片,PHP常用数组函数小结
    查看>>
    php CI框架单个file表单多文件上传例子
    查看>>
    php composer
    查看>>
    reflow和repaint引发的性能问题
    查看>>
    Reflection反射机制原理、使用场景 及 缺陷
    查看>>
    php csv 导出
    查看>>
    php curl 实例+详解
    查看>>
    php curl_init函数用法(http://blog.sina.com.cn/s/blog_640738130100tsig.html)
    查看>>
    php curl_multi批量发送http请求
    查看>>
    php curl请求微信发红包接口出现错误:Peer's Certificate issuer is not recognized.
    查看>>
    PHP curl请求错误汇总和解决方案
    查看>>
    php declare(ticks=1)
    查看>>
    UVA 10474
    查看>>