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

    你可能感兴趣的文章
    Openlayers实战:绘制带箭头的线
    查看>>
    Openlayers实战:绘制点、线、圆、多边形
    查看>>
    Openlayers实战:绘制矩形,正方形,正六边形
    查看>>
    Openlayers实战:自定义放大缩小,显示zoom等级
    查看>>
    Openlayers实战:自定义版权属性信息
    查看>>
    Openlayers实战:输入WKT数据,输出GML、Polyline、GeoJSON格式数据
    查看>>
    Openlayers实战:选择feature,列表滑动,定位到相应的列表位置
    查看>>
    Openlayers实战:非4326,3857的投影
    查看>>
    Openlayers高级交互(1/20): 控制功能综合展示(版权、坐标显示、放缩、比例尺、测量等)
    查看>>
    Openlayers高级交互(10/20):绘制矩形,截取对应部分的地图并保存
    查看>>
    Openlayers高级交互(11/20):显示带箭头的线段轨迹,箭头居中
    查看>>