MiniHttpServer
Mini HTTP Server which can be embed in EXE, Writen in C#(.net framework 2.0).
HTTP request dispatch/route, you can register the handlers for a specific url. Url match using start with in order, so that register the more specific in first. For example:
server.RegisterHandler("/index/1", FirstIndexHandler);
server.RegisterHandler("/index", GeneralIndexHandler);
When url request be handled, stop propagation. That's when we requst the "/index/1", and it's handle already. GeneralIndexHandler will NOT execute.
Usage
using Jatsz.MiniHttpServer; MiniHttpServer server = new MiniHttpServer(); //start http server on port of 8081 //register the handler(s) and start the server
server.RegisterHandler("/index", IndexHandler);
server.Start(); void IndexHandler(object sender, ContextEventArgs e)
{
string responseString = string.Format("<HTML><BODY> Hello world! {0}</BODY></HTML>", DateTime.Now); // Obtain a response object.
HttpListenerResponse response = e.Context.Response;
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
// Get a response stream and write the response to it.
response.ContentLength64 = buffer.Length;
System.IO.Stream output = response.OutputStream;
output.Write(buffer, , buffer.Length);
// You must close the output stream.
output.Close();
}
MiniHttpServer的更多相关文章
随机推荐
- C++-STL-(map用法)
http://blog.csdn.net/sunshinewave/article/details/8067862
- 洛谷P1113 杂务
题目描述 John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它.比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作.尽早将所有杂务完成是必要的,因为 ...
- 【最短路】【dijkstra】【二进制拆分】hdu6166 Senior Pan
题意:给你一张带权有向图,问你某个点集中,两两结点之间的最短路的最小值是多少. 其实就是dijkstra,只不过往堆里塞边的时候,要注意塞进去它是从集合中的哪个起始点过来的,然后在更新某个点的答案的时 ...
- JVM命令-java服务器故障排查
一.top(Linux命令) 执行top命令: (查看进程15477的详细情况,下文用到) 系统信息(前五行): 第1行:Top 任务队列信息(系统运行状态及平均负载),与uptime命令结果相 ...
- uva10392 Factoring Large Numbers
uva10392 Factoring Large Numbers 本文涉及的知识点是,使用线性筛选法得到素数表. Table of Contents 1 题目 2 思路 3 参考 1 题目 ===== ...
- FFT算法的完整DSP实现
傅里叶变换或者FFT的理论参考: [1] http://www.dspguide.com/ch12/2.htm The Scientist and Engineer's Guide to Digita ...
- 配置安全证书的Etcd集群
不知在哪篇技术文档中看到,kubernetes master和etcd分开部署模式,因为集群的状态都保存在etcd中,这样当kubernetes master挂掉后,通过API Server交互的Sc ...
- ubuntu安装elasticSearch及插件
原文地址:http://www.niu12.com/article/18 前提 1.安装好Java1.8以上环境并配置好JAVA_HOME(elasticsearch运行环境) 2.node环境6.5 ...
- 万里长征第二步——django个人博客(第七步 ——上传文件)
在项目目录下新建一个 ‘uploads’文件夹以保存上传的文件 配置setting.py文件 MEDIA_URL = '/uploads/' MEDIA_ROOT = os.path.join(BAS ...
- C#.net开发 List与DataTable相互转换 【转】
http://blog.csdn.net/shuizhaoshui/article/details/51425527 在.NET开发中,操作关系型数据库提取数据经常用到DataTable.ASP.NE ...