[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), 总是不对,最后终于试对了,这里记录下,方便以后 ...
随机推荐
- string之substring的用法
package com.j1; public class StringTest1 { public static void main(String[] args) { String s =" ...
- javascript 模仿 html5 placeholder
<form action="?action=deliver" method="post" class="deliver-form"&g ...
- 从反编译的角度去观察C#6.0
1. 自动属性初始化 (Initializers for auto-properties) 1.1 C#6.0 之前的写法 public class FirstExperience { private ...
- linux安装rz和sz
rz命令是用来上传文件 sz命令是用来下载文件 1.系统安装了yum 以root用户登录: yum install lrzsz -y 2.没有安装yum 以下地址中有详解 http://jingyan ...
- o2o
o2o(电子商务名词) -- 百度名片 O2O即Online To Offline(在线离线/线上到线下),是指将线下的商务机会与互联网结合,让互联网成为线下交易的前台,这个概念最早来源于美国.O2O ...
- 基于nginx的rtmp的服务器(nginx-rtmp-module)
一,首先下载安装nginx需要依赖的库文件: 1.1,选定源码目录 选定目录 /usr/local/RTMP cd /usr/local/RTMP 1.2,安装PCRE库 cd /usr/local/ ...
- c#中将默认常量(32bit)转换为8bit
// //将int进制转换 // private byte hex(int myHex) { byte[] a = BitConverter.GetBytes(myHex); return a[0]; ...
- php,apache伪静态(1转)
1.检测Apache是否支持mod_rewrite通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有apache2handler ...
- Python入门学习之input()与raw_input()的区别
登陆博客时才发现已经注册一年了,由于之前一直都没有打算从事软件开发行业,所以博客便被束之高阁,软件开发,对于我来说,是成长,更是磨炼.头脑风暴总是来去自由,记录灵感,与大家一起共享思维进步的成果. P ...
- javascript中遍历EL表达式List集合中的值
http://www.cnblogs.com/limeiky/p/6002900.html