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

    你可能感兴趣的文章
    PoE三种标准:标准 PoE、PoE+、PoE++,网络工程师必知!
    查看>>
    POI:POI+JXL实现xls文件添加水印
    查看>>
    POJ 2488:A Knight's Journey
    查看>>
    poj 2763 Housewife Wind
    查看>>
    POJ 3083 Children of the Candy Corn 解题报告
    查看>>
    POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
    查看>>
    poj 3262 Protecting the Flowers 贪心
    查看>>
    poj 3264(简单线段树)
    查看>>
    poj 3277 线段树
    查看>>
    POJ 3349 Snowflake Snow Snowflakes
    查看>>
    poj 3422 Kaka's Matrix Travels (费用流 + 拆点)
    查看>>
    poj 3539 Elevator——同余类bfs
    查看>>
    poj 3628 Bookshelf 2
    查看>>
    poj1936 假期计划第一水
    查看>>
    poj1958-汉诺四塔问题(三种方法)
    查看>>
    PostgreSQL学习总结(11)—— PostgreSQL 常用的高可用集群方案
    查看>>
    PostgreSQL学习总结(1)—— PostgreSQL 入门简介与安装
    查看>>
    PostgreSQL学习总结(6)—— PostgreSQL 模式(SCHEMA)详解
    查看>>
    PostgreSQL学习笔记:PostgreSQL vs MySQL
    查看>>
    PostgreSQL数据库pg_dump命令行不输入密码的方法
    查看>>