![Crow logo](http://i.imgur.com/wqivvjK.jpg)
Crow is C++ microframework for web. (inspired by Python Flask)
[![Travis Build](https://travis-ci.org/ipkn/crow.svg?branch=master)](https://travis-ci.org/ipkn/crow)
[![Coverage Status](https://coveralls.io/repos/ipkn/crow/badge.svg?branch=master)](https://coveralls.io/r/ipkn/crow?branch=master)
```c++
#include "crow.h"
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
return "Hello world";
});
app.port(18080).multithreaded().run();
}
```
## Features
- Easy routing
- Similiar to Flask
- Type-safe Handlers (see Example)
- Very Fast
- ![Benchmark Result in one chart](https://docs.google.com/spreadsheets/d/1KidO9XpuwCRZ2p_JRDJj2aep61H8Sh_KDOhApizv4LE/pubchart?oid=2041467789&format=image)
- More data on [crow-benchmark](https://github.com/ipkn/crow-benchmark)
- Fast built-in JSON parser (crow::json)
- [Mustache](http://mustache.github.io/) based templating library (crow::mustache)
- Header only
- Provide an amalgamated header file `crow_all.h' with every features
- Middleware support
## Still in development
- ~~Built-in ORM~~
- Check [sqlpp11](https://github.com/rbock/sqlpp11) if you want one.
## Examples
#### JSON Response
```c++
CROW_ROUTE(app, "/json")
([]{
crow::json::wvalue x;
x["message"] = "Hello, World!";
return x;
});
```
#### Arguments
```c++
CROW_ROUTE(app,"/hello/<int>")
([](int count){
if (count > 100)
return crow::response(400);
std::ostringstream os;
os << count << " bottles of beer!";
return crow::response(os.str());
});
```
Handler arguments type check at compile time
```c++
// Compile error with message "Handler type is mismatched with URL paramters"
CROW_ROUTE(app,"/another/<int>")
([](int a, int b){
return crow::response(500);
});
```
#### Handling JSON Requests
```c++
CROW_ROUTE(app, "/add_json")
.methods("POST"_method)
([](const crow::request& req){
auto x = crow::json::load(req.body);
if (!x)
return crow::response(400);
int sum = x["a"].i()+x["b"].i();
std::ostringstream os;
os << sum;
return crow::response{os.str()};
});
```
## How to Build
If you just want to use crow, copy amalgamate/crow_all.h and include it.
### Requirements
- C++ compiler with good C++11 support (tested with g++>=4.8)
- boost library
- CMake for build examples
- Linking with tcmalloc/jemalloc is recommended for speed.
- Now supporting VS2013 with limited functionality (only run-time check for url is available.)
### Building (Tests, Examples)
Out-of-source build with CMake is recommended.
```
mkdir build
cd build
cmake ..
make
```
You can run tests with following commands:
```
ctest
```
### Installing missing dependencies
#### Ubuntu
sudo apt-get install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so
#### OSX
brew install boost google-perftools
### Attributions
Crow uses the following libraries.
qs_parse
https://github.com/bartgrantham/qs_parse
Copyright (c) 2010 Bart Grantham
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
基于LSTM和CRF的深度学习中文分词完整源码(python).zip (198个子文件)
BUILD.boost 1KB
BUILD 3KB
BUILD 1KB
BUILD 1KB
BUILD 1KB
BUILD 865B
BUILD 507B
BUILD 478B
BUILD 336B
BUILD 281B
BUILD 263B
BUILD 250B
BUILD 220B
BUILD 204B
BUILD 179B
BUILD 0B
boost.bzl 1KB
word2vec.c 26KB
word2phrase.c 9KB
compute-accuracy.c 5KB
word-analogy.c 5KB
jsonxx.cc 33KB
tf_seg_model.cc 12KB
pos_tagger.cc 10KB
word2vec_vob.cc 5KB
distance.cc 5KB
test_seg.cc 4KB
seg_backend_api.cc 4KB
tfmodel.cc 3KB
gen_seg_eval.cc 3KB
sentence_breaker.cc 3KB
viterbi_decode.cc 2KB
basic_vocab.cc 2KB
test_ac_scanner.cc 1KB
py_word2vec_vob.cc 1KB
test_breaker.cc 1KB
base.cc 256B
empty.cc 0B
empty.cc 0B
FindTcmalloc.cmake 981B
configure 835B
unittest.cpp 31KB
example.cpp 4KB
example_vs.cpp 3KB
example_with_all.cpp 3KB
example_chat.cpp 3KB
example_ws.cpp 1KB
mustachetest.cpp 756B
example_ssl.cpp 518B
helloworld.cpp 164B
dummy 0B
.gitignore 237B
.gitignore 181B
.gitmodules 0B
glog-0.3.4.tar.gz 500KB
gflags-2.0.tar.gz 410KB
crow_all.h 305KB
http_parser_merged.h 78KB
pybind11.h 52KB
cast.h 34KB
json.h 29KB
routing.h 28KB
pytypes.h 19KB
http_connection.h 17KB
numpy.h 15KB
basic_string_util.h 15KB
mustache.h 15KB
utility.h 14KB
common.h 13KB
attr.h 13KB
websocket.h 12KB
stl_bind.h 12KB
eigen.h 11KB
jsonxx.h 10KB
query_string.h 9KB
operators.h 8KB
descr.h 7KB
stl.h 6KB
http_server.h 6KB
app.h 6KB
ac_scanner.h 5KB
middleware.h 4KB
parser.h 4KB
logging.h 3KB
common.h 3KB
http_response.h 3KB
json_util.h 2KB
middleware_context.h 2KB
socket_adaptors.h 2KB
tf_seg_model.h 2KB
dumb_timer_queue.h 2KB
functional.h 2KB
word2vec_vob.h 2KB
http_request.h 1KB
pos_tagger.h 1KB
typeid.h 1KB
complex.h 1KB
sentence_breaker.h 1KB
viterbi_decode.h 982B
tfmodel.h 881B
共 198 条
- 1
- 2
资源评论
龙年行大运
- 粉丝: 1158
- 资源: 3823
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- TH2024005基于微信平台的文玩交易小程序ssm.zip
- java高校职工工资管理系统
- 零基础学AI-python语言:python基础语法(课件部分)
- IMT5G推进组发布5G无人机应用白皮书
- 基于Java SSM写的停车场管理系统,加入了车牌识别和数据分析
- 2025年P气瓶充装模拟考试卷
- 【java毕业设计】基于spring boot心理健康服务系统(springboot+vue+mysql+说明文档).zip
- 基于vue+ssm816企业在线培训系统全套(源码+万字LW).zip
- 【java毕业设计】springbootJava物业智慧系统(springboot+vue+mysql+说明文档).zip
- 【源码+数据库】基于java Swing+mysql实现的学生选课信息系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功