Node.js
bboyjoe
勇气与智慧并行,才能越过人生的一座座高山。
展开
-
Node.js基础实战
一.http模块1.搭建http服务const http = require('http');let server = http.createServer((req,res) => { console.log(req.method + ":" + req.url); res.writeHead(200,{'Content-Type':'text/html; charset=UT...原创 2018-04-24 09:43:40 · 290 阅读 · 0 评论 -
koa基础实践
1.http response的类型const Koa = require('koa');const app = new Koa();const main = ctx => { if (ctx.request.accepts('xml')) { ctx.response.type = 'xml'; ctx.response.body = '<...原创 2018-04-25 16:13:09 · 350 阅读 · 0 评论 -
koa基础实践
1.访问静态文件: 使用中间件koa-staticconst koa = require('koa');const static = require('koa-static');let server = new koa();server.listen(8080);// 访问静态文件server.use(static('www')); 在根目录创建www文件夹,并新建...原创 2018-08-05 23:27:30 · 460 阅读 · 0 评论 -
Node.js基础实战
const http = require('http')const fs = require('fs')const path = require('path')const server = http.createServer((req, res) => { const {url, method} = req if (url === '/' && method...原创 2019-06-19 14:28:28 · 170 阅读 · 0 评论 -
封装一个简易的express,实现简单路由
const http = require('http')const url = require('url')let router = []class Application { get (path, handler) { router.push({ path, method: 'get', handler }) } liste...原创 2019-06-19 14:31:58 · 618 阅读 · 0 评论 -
Node.js爬虫实践
// 用来发送https请求const originRequest = require("request");// 类似服务端jqueryconst cheerio = require("cheerio");// 解码const iconv = require("iconv-lite");function request(url, callback) { const optio...原创 2019-06-19 17:17:13 · 761 阅读 · 0 评论 -
Koa实现一个简易登录
const Koa = require('koa')const Router = require('koa-router')const render = require('koa-art-template')const static = require('koa-static')const bodyParser = require('koa-bodyparser')const sess...原创 2019-06-11 17:55:51 · 1395 阅读 · 0 评论