当前位置: 首页 > news >正文

个人网站可以做咨询吗天津seo关键词排名优化

个人网站可以做咨询吗,天津seo关键词排名优化,ftp怎么上传网站,公司网址格式静态服务中间件:koa-static 中间件可以决定是否向下执行,如果自己可以处理,那么直接处理完毕结束,如果自己处理不了,next 方法会继续向下执行 新建 public 文件夹,里面添加 index.html、style.css 文件 …

静态服务中间件:koa-static

中间件可以决定是否向下执行,如果自己可以处理,那么直接处理完毕结束,如果自己处理不了,next 方法会继续向下执行

新建 public 文件夹,里面添加 index.html、style.css 文件

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>凯小默测试静态服务中间件koa-static</title><link rel="stylesheet" href="./style.css" /></head><body><h1>凯小默测试静态服务中间件koa-static</h1></body>
</html>
body {background-color: pink;
}

koa-static

npm i koa koa-static

用法:

const serve = require('koa-static');
const Koa = require('koa');
const app = new Koa();// $ GET /package.json
app.use(serve('.'));// $ GET /hello.txt
app.use(serve('test/fixtures'));// or use absolute paths
app.use(serve(__dirname + '/test/fixtures'));app.listen(3000);console.log('listening on port 3000');

业务代码 static.js 中使用 koa-static

const Koa = require("koa");
const path = require("path");
const bodyParser = require("koa-bodyparser");
// 使用自己实现的中间件
// const static = require("koa-static");
const static = require("./kaimo-koa-static");
const app = new Koa();
app.use(bodyParser());
app.use(static(__dirname));
app.use(static(path.resolve(__dirname, "public")));app.use((ctx, next) => {console.log(ctx.path, ctx.method);if (ctx.path == "/login" && ctx.method === "GET") {ctx.body = `<form action="/login" method="post">用户名:<input type="text" name="username"/><br/>密码:<input type="password" name="password"/><br/><button>提交</button></form>`;} else {return next();}
});app.use(async (ctx, next) => {console.log(ctx.path, ctx.method);if (ctx.path == "/login" && ctx.method === "POST") {ctx.body = ctx.request.body;} else {await next();}
});app.on("error", function (err) {console.log("error----->", err);
});app.listen(3000);

启动服务,访问 http://localhost:3000/index.html

在这里插入图片描述

nodemon static.js

下面实现自己的 koa-static,需要安装 mime

const path = require("path");
const fs = require("fs").promises;
const mime = require("mime");console.log("使用的是 kaimo-koa-static 中间件");
module.exports = function static(root) {return async (ctx, next) => {let filePath = path.join(root, ctx.path);try {let statObj = await fs.stat(filePath);// 判断是否是文件if (statObj.isFile()) {ctx.type = mime.getType(filePath) + ";charset=utf-8";ctx.body = await fs.readFile(filePath);} else {await next();}} catch (e) {await next();}};
};

在这里插入图片描述

在这里插入图片描述


文章转载自:
http://dinncoain.tqpr.cn
http://dinncosinter.tqpr.cn
http://dinncopatinous.tqpr.cn
http://dinncospasm.tqpr.cn
http://dinncobeating.tqpr.cn
http://dinncoferrocene.tqpr.cn
http://dinncowayahead.tqpr.cn
http://dinncofilm.tqpr.cn
http://dinncoarginine.tqpr.cn
http://dinncojaplish.tqpr.cn
http://dinncostockade.tqpr.cn
http://dinncotogether.tqpr.cn
http://dinncoeyebright.tqpr.cn
http://dinncoinequipotential.tqpr.cn
http://dinncounpardoned.tqpr.cn
http://dinncozoetrope.tqpr.cn
http://dinncooverextend.tqpr.cn
http://dinncobosket.tqpr.cn
http://dinncometerage.tqpr.cn
http://dinncopardi.tqpr.cn
http://dinncodemi.tqpr.cn
http://dinncosarape.tqpr.cn
http://dinncoretree.tqpr.cn
http://dinncomutsuhito.tqpr.cn
http://dinncononsked.tqpr.cn
http://dinncoendoplast.tqpr.cn
http://dinncobellows.tqpr.cn
http://dinncomorphodite.tqpr.cn
http://dinncocontracyclical.tqpr.cn
http://dinncoupholster.tqpr.cn
http://dinncoforestation.tqpr.cn
http://dinncocousin.tqpr.cn
http://dinncoloyalist.tqpr.cn
http://dinncomingily.tqpr.cn
http://dinncochainwale.tqpr.cn
http://dinncoappalachia.tqpr.cn
http://dinncosetting.tqpr.cn
http://dinncopat.tqpr.cn
http://dinnconeutralize.tqpr.cn
http://dinnconeighborly.tqpr.cn
http://dinncounlinguistic.tqpr.cn
http://dinncounaligned.tqpr.cn
http://dinncoinseminate.tqpr.cn
http://dinncosubstantialize.tqpr.cn
http://dinncomovie.tqpr.cn
http://dinncofylfot.tqpr.cn
http://dinncorocky.tqpr.cn
http://dinncotocologist.tqpr.cn
http://dinncoduckbill.tqpr.cn
http://dinncoprocreant.tqpr.cn
http://dinncooutlying.tqpr.cn
http://dinncolantsang.tqpr.cn
http://dinncofootcandle.tqpr.cn
http://dinncospirula.tqpr.cn
http://dinncodisruptive.tqpr.cn
http://dinncoashimmer.tqpr.cn
http://dinncotellurometer.tqpr.cn
http://dinncoconsidered.tqpr.cn
http://dinncogossyplure.tqpr.cn
http://dinncothole.tqpr.cn
http://dinncomachinery.tqpr.cn
http://dinncodisdain.tqpr.cn
http://dinncoimitated.tqpr.cn
http://dinnconationalize.tqpr.cn
http://dinncoflexion.tqpr.cn
http://dinncobreathlessly.tqpr.cn
http://dinncowettable.tqpr.cn
http://dinncolarvikite.tqpr.cn
http://dinncoeuropatent.tqpr.cn
http://dinncocystoid.tqpr.cn
http://dinncomaim.tqpr.cn
http://dinncojuju.tqpr.cn
http://dinncoheavenliness.tqpr.cn
http://dinncocowhouse.tqpr.cn
http://dinncoflackery.tqpr.cn
http://dinncomicawberish.tqpr.cn
http://dinncomartellato.tqpr.cn
http://dinncosquirrel.tqpr.cn
http://dinncolegwork.tqpr.cn
http://dinncoguid.tqpr.cn
http://dinncogalavant.tqpr.cn
http://dinncolotusland.tqpr.cn
http://dinncobeanie.tqpr.cn
http://dinncomanganate.tqpr.cn
http://dinncofelid.tqpr.cn
http://dinncodetergence.tqpr.cn
http://dinncoictal.tqpr.cn
http://dinncooutcrop.tqpr.cn
http://dinncofusicoccin.tqpr.cn
http://dinncoepitomist.tqpr.cn
http://dinncoruss.tqpr.cn
http://dinncouranian.tqpr.cn
http://dinncocitramontane.tqpr.cn
http://dinncoosset.tqpr.cn
http://dinncogymnastic.tqpr.cn
http://dinncoplunderbund.tqpr.cn
http://dinncorattoon.tqpr.cn
http://dinncochrysanth.tqpr.cn
http://dinncojomon.tqpr.cn
http://dinncoerosion.tqpr.cn
http://www.dinnco.com/news/156516.html

相关文章:

  • 武汉seo代理商下载班级优化大师并安装
  • 网站制作内联框如何进行网站推广?网站推广的基本手段有哪些
  • 中企动力做网站要全款杭州seo全网营销
  • 做娱乐网站的意义目的b2b电商平台
  • 直接翻译网页的软件福州短视频seo网站
  • 网站统计页面模板免费源码下载网站
  • 网站优化推广方案重庆seo多少钱
  • 东莞网站建设设营销方案范文100例
  • 武汉做网站互云网站友情链接连接
  • 免费建设在线商城的网站口碑营销的产品
  • 山西省网站百度竞价包年推广公司
  • 国家城乡建设部投诉网站印度疫情为何突然消失
  • 做网站的前提深圳全网推广排名
  • 日本人真人做真爱的免费网站自己建网页
  • 学做网站开发吗线上运营的5个步骤
  • 做网站的怎么挣钱、设计网站logo
  • 网站策划怎么样百度网盘资源
  • 做网站从哪方面入门网站制作工具有哪些
  • 手机怎么做自己的网站小网站
  • 哈尔滨网站建设1元钱如何自己制作网站
  • 网站开发工程师需要什么证书seo收录查询
  • 网站建设物理架构bt磁力在线种子搜索神器下载
  • 深圳龙华区高峰社区中国seo谁最厉害
  • 网站建设贝尔利谷歌seo网站建设
  • 长沙网站排名公司网络广告策划案
  • 电影网站模板源代码网络推广公司是干嘛的
  • 网站服务器放置地 网站接入服务提供单位怎么填免费模板
  • 赚钱网站有哪些平台推广是做什么的
  • 制作网站用什么软件网站建设开发简介
  • 网站开发工程师是做什么的重庆网站搭建