[Hapi.js] Serving static files
hapi does not support serving static files out of the box. Instead it relies on a module called Inert. This lesson will cover serving static files using Inert's custom handlers.
'use strict'
var Hapi = require( 'hapi' );
var Boom = require('boom');
var Path = require('path'); /**
* set up server connection
* @type {"hapi".Server}
*/
var server = new Hapi.Server();
server.connection( {
host: 'localhost',
port: 8000
} ); server.register( require('inert'), function(){ // server an file
server.route({
method: 'GET',
path: '/2.png',
handler: {
file: Path.join(__dirname, 'public/images/2.png')
}
}); // server an directory
server.route({
method: 'GET',
path: '/images/{param*}',
handler: {
directory: {
path: Path.join(__dirname, 'public/images')
}
}
})
});
[Hapi.js] Serving static files的更多相关文章
- 【Azure 应用服务】App Service For Windows 环境中部署Python站点后,如何继续访问静态资源文件呢(Serving Static Files)?
问题描述 当创建一个App Service 后,运行时环境和版本选择Windows 和 Python 3.6. 登录Kudu 站点查看,默认的文件有 web.config, hostingstart- ...
- [Node.js] Serve Static Files with Express
In this lesson we will find out how to serve static assets (images, css, stylesheets, etc.) with Exp ...
- Adding Cache-Control headers to Static Files in ASP.NET Core
Thanks to the ASP.NET Core middleware pipeline, it is relatively simple to add additional HTTP heade ...
- 前端技巧:禁止浏览器static files缓存篇(转)
前端技巧:禁止浏览器static files缓存篇 由于CSS/JS文件经常需要改动,前端调试时是不希望浏览器缓存这些文件的. 本文记录博主的经验. Meta法 目前在chrome调试还没有遇到问题, ...
- [转]ASP.NET Core: Static Files cache control using HTTP Headers
本文转自:https://www.ryadel.com/en/asp-net-core-static-files-cache-control-using-http-headers/ Every sea ...
- Settings Django Static Files
静态文件是通过django.contrib.staticfiles来管理的. 配置Django静态文件,Djang官网静态文件配置介绍.简言之,通过以下三个步骤来配置和加载静态文件: 设置静态文件别名 ...
- Django App(五) load static files
经过前面4篇的努力,已经基本完成了,polls站点的功能,但是所有界面都没有涉及样式,和JavaScript的导入.到目前为止了解到的Django是通过解析Url来完成对客户端的响应的,那么组成站点所 ...
- js class static property & public class fields & private class fields
js class static property class static property (public class fields) const log = console.log; class ...
- Django 静态文件配置(static files)
Django version: 1.9 Python versrion: 3.5.2 这几天Django配置静态文件(本例是要加载index.css), 总是不对,最后终于试对了,这里记录下,方便以后 ...
随机推荐
- EasyInvoice 使用教程 - (1) 认识 EI
原视频下载地址:EI 主界面介绍 1. 主界面截图 2. 基础资料界面截图 3. 管理员 界面截图
- getAttribute()与getParameter的区别
当两个Web组件之间为转发关系时,转发源会将要共享 request范围内的数据先用setAttribute将数据放入到HttpServletRequest对象中,然后转发目标通过 getParamet ...
- EF数据建模(一)
大中型软件开发过程中常会使用ORM技术,ORM全称是“对象-关系映射Object-Relation-Mappping”.是将数据库中的数据对象的形式表现出来,并将通过面向对象的方式将这些对象组织起来, ...
- ASP.NET中过滤HTML字符串的两个方法
先记下来,以作备用! /// <summary>去除HTML标记 /// /// </summary> /// <param name="Htmlstring& ...
- iOS中UISearchBar(搜索框)使用总结
http://my.oschina.net/u/2340880/blog/509756
- python中raw_input()与input()
raw_input([prompt]) input([prompt]) # prompt:如果参数存在,直接输出到屏幕上,不会再另起一行 raw_input 如其字面意思一样,返回输入字符的字符串形式 ...
- php的一些小笔记--时间函数
strtotime 返回UNIX时间戳 .这个函数可以用来计算前天,昨天,后天,明天 例如明天:date('Y-m-d H:is',strtotime('+1 day')) day>1是复数 ...
- 有关service
在symfony2 服务注入容器的时候参数语法可以是这样: cellcom.twig.menu_extension: class: Cellcom\WebBundle\Twig\Extension\M ...
- apt软件包管理
apt软件包管理 ---- http://wiki.ubuntu.org.cn/UbuntuHelp:AptGet/Howto/zh APT HOWTO ---- http://www.d ...
- 《Programming WPF》翻译 第3章 1.什么是控件
原文:<Programming WPF>翻译 第3章 1.什么是控件 对于一个应用程序而言,控件是搭建用户界面的积木.它们具备交互式的特征,例如文本框.按钮以及列表框.尽管如此,WPF还有 ...