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的更多相关文章
随机推荐
- 【20181019T2】硬币【矩阵快速幂优化DP】
题面 [错解] 哎\(N \leq 50\)?双向搜索? 切了切-- 等下,好像要求方案数-- 好像搜不了 哎他给\(V_{i} | V_{i+1}\)干嘛? 肯定有用啊 为了体现条件的用处,我在搜下 ...
- [BZOJ 2427] 软件安装
Link: BZOJ 2427 传送门 Solution: 只看样例的话会以为是裸的树形$dp$…… 但实际上题目并没有说明恰好仅有一个物品没有依赖项 因此原图可能由是由多棵树与多个图组成的 先跑一遍 ...
- 【组合数】【乘法逆元】 Codeforces Round #404 (Div. 2) D. Anton and School - 2
http://codeforces.com/blog/entry/50996 官方题解讲得很明白,在这里我复述一下. 枚举每个左括号,考虑计算一定包含其的简单括号序列的个数,只考虑其及其左侧的左括号, ...
- 十. 图形界面(GUI)设计14.键盘事件
键盘事件的事件源一般丐组件相关,当一个组件处于激活状态时,按下.释放或敲击键盘上的某个键时就会发生键盘事件.键盘事件的接口是KeyListener,注册键盘事件监视器的方法是addKeyListene ...
- Codeforces Round #344 (Div. 2) C. Report 其他
C. Report 题目连接: http://www.codeforces.com/contest/631/problem/C Description Each month Blake gets th ...
- Educational Codeforces Round 9 A. Grandma Laura and Apples 水题
A. Grandma Laura and Apples 题目连接: http://www.codeforces.com/contest/632/problem/A Description Grandm ...
- JS对象和数组
/* 数组和对象 [JavaScript 权威指南 第五版] */ /* 对象: 是一个无序属性集合, 每个属性都有自己的名字和值 */ /* 创建对象简单方法, 对象直接量 */ var obj = ...
- 使用idea搭建Spring boot开发初始环境
准备工作 将以下代码加入idea的live template,命名为springbootStartup <parent> <groupId>org.springframewor ...
- Jenkins构建Maven多模块项目时,单独编译子模块,并且不触发构建其它模块
一.Jenkins构建Maven多模块项目时,单独编译子模块 配置: 1.Root POM指向父pom.xml 2.Goals and options指定构建模块的参数:mvn -pl jsoft-w ...
- Navicat无法连接到MySQL
今天新装的linux,装好以后想用Navicat连接一下数据库,发现连接不上 思路,捋一下 第一种:Access denied for user 'root'@'localhost' (using p ...