介绍
刚好需要做一个http服务,所以简单的研究了下几种语言http框架的入门使用
C++
libevent+http
自己写了一个多线程版本的,封装了大部分功能,只要注册指定 uri的回调处理就可以了。
性能、并发性良好。
mongoose
之前在某个服务里面使用,主要用于获取配置,调用频率不高,使用简单
python
Flask
使用vs2019 创建一个flask工程,然后按照提示使用pip 安装flask,就可以实现一个简单的http服务。
使用起来还是挺简单的。没验证过性能、并发性如何。
go
gin
使用起来和flask差不多。
go就是需要科学上网比较麻烦
lua
openrestry
nginx.conf 配置文件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34     server {
     listen       8090;
     server_name  localhost;
     # 获取post 请求的body
     lua_need_request_body on;
     # 对于开发研究,可以对代码 cache 进行关闭,这样不必每次都重新加载 nginx。
     lua_code_cache off;
     #charset koi8-r;
     #access_log  logs/host.access.log  main;
     location / {
         root   html;
         index  index.html index.htm;
     }
     location /v1.0/open/ai 
     {
        default_type text/html;
         content_by_lua_file ai.lua;
     }
     location /v1.0/open/action
     {
        default_type text/html;
         content_by_lua_block 
         {
             dofile("action.lua")
         }
     }
     #error_page  404              /404.html;
     # redirect server error pages to the static page /50x.html
     #
     error_page   500 502 503 504  /50x.html;
     location = /50x.html {
         root   html;
     }
}
| 1 | 在解压根目录下创建 ai.lua、action.lua 内容如下 | 
| 1 | nginx lua api: | 
其他语言
比如.net、java、js 应该有更多http服务框架,这部分不了解!
 
        