Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ayaankhan98/crow
Browse files Browse the repository at this point in the history
  • Loading branch information
ayaankhan98 committed Dec 1, 2020
2 parents acab73e + 6c7bef1 commit 6f31e59
Show file tree
Hide file tree
Showing 41 changed files with 891 additions and 124 deletions.
Empty file removed .gitmodules
Empty file.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,21 @@ env:
- secure: "CQRYHWlg/WDu5DBUeDwGo+rPeOofN08DhiLUNlLtZjMWaRyP0Cop1qVaFs8ESOkYiWek2MdpvjZud+7hL+yx2ogvNx4SfHpUMCDKYgcX+YQ9MmYwabvoKq8N6KVXE3lbPp549TonHdDuNCWNKRniNjYtrij5J+IiIiT8/6Txo2p9RWk6YSUTdXJ9YrfuWMtRuF5uo9SHGyujv8pOJKedrwWoSBbHT44jnwfHMVe/C8jgjwlrJ9N3iXOtsG6sj+UTS8vOpL+jpBONEbBfHgSFU57I7IFNdPQbSObpVwG9geOAHT7IQQyQ9hp2AJoFxxVURB5SzqztDDpQ0XIF76vuH9tA/fF2pwDsLRmcLR8JU1TCmQgvnlYD0+Or9S1Dq0tQME5AP+21Hk2zVcGdbgQP7XWix758F0vpOXa4PXw8TmAjP2jKyAMHlzR3icr3+OmKSK3uXMMt2HSMOJQ+JvFxr//DM493i/VGyeY25/zu3A9RstiE+1d82Fi9xKOmMf4smvSkjOgT0b727jqNbNe6CvEKQUmqHabzYRQzUVz6WPVDHBxZP7AiKmZIVQXYnDsVXywStkSoxxY5En6XKpq0GR3bIVtUMORgZPoZi7Jni+/4EckcYH8g9mpsQf9tPRcOZ2WIvt5gqp2MZuwBLBRcbxihuECfBscqdeA0oDU5AZw="
- GH_REPO_NAME: crow
- DOXYFILE: $TRAVIS_BUILD_DIR/Doxyfile
- GH_REPO_REF: github.com/mrozigor/crow.git
- THEME_REPO_REF: github.com/mrozigor/darxygen.git
- GH_REPO_REF: github.com/crowcpp/crow.git
- THEME_REPO_REF: github.com/crowcpp/darxygen.git


addons:
apt:
packages:
- libboost-all-dev
- doxygen
- doxygen-doc
- doxygen-latex
- doxygen-gui
- mkdocs
- graphviz

before_install:
- if [ "$TRAVIS_COMPILER" == "gcc" -a "$TRAVIS_CPU_ARCH" == "amd64" ]; then export PUSH_COVERAGE=ON; fi
- if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" -a "$PUSH_COVERAGE" == "ON" ]; then export TRAVIS_BUILD_DOCS=ON; fi
- if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" -a "$PUSH_COVERAGE" == "ON" ]; then export TRAVIS_BUILD_DOCS=ON; pip install mkdocs-material; fi

install:
- if [ "$PUSH_COVERAGE" == "ON" ]; then pip install --user cpp-coveralls; fi
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(PROJECT_INCLUDE_DIR

include_directories("${PROJECT_INCLUDE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}") # To include crow_all.h

add_subdirectory(examples)

Expand Down
10 changes: 2 additions & 8 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ TAB_SIZE = 2

ALIASES =

# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class"
# will allow you to use the command class in the itcl::class meaning.

TCL_SUBST =

# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C. For
# instance, some of the names that are used will be different. The list of all
Expand Down Expand Up @@ -990,7 +984,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.

USE_MDFILE_AS_MAINPAGE = readme.md
USE_MDFILE_AS_MAINPAGE = README.md

#---------------------------------------------------------------------------
# Configuration options related to source browsing
Expand Down Expand Up @@ -1119,7 +1113,7 @@ GENERATE_HTML = YES
# The default directory is: html.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_OUTPUT = html
HTML_OUTPUT = site/reference

# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
# generated HTML page (for example: .htm, .php, .asp).
Expand Down
110 changes: 43 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
![Crow logo](https://pixeldrain.com/api/file/DMc7xYye)
<p align="center"><img src="https://pixeldrain.com/api/file/DMc7xYye" width=600></p>

Crow is a C++ microframework for web. (inspired by Python Flask)
<h4 align="center">A Fast and Easy to use microframework for the web.</h4>
<p align="center">
<a href="https://travis-ci.com/crowcpp/crow"><img src="https://travis-ci.com/crowcpp/crow.svg?branch=master" alt="Build Status"></a>
<a href="https://coveralls.io/github/CrowCpp/crow?branch=master"><img src="https://coveralls.io/repos/github/CrowCpp/crow/badge.svg?branch=master" alt="Coverage Status"></a>
<a href="https://crowcpp.github.io/crow"><img src="https://img.shields.io/badge/-Documentation-informational" alt="Documentation"></a>
<a href="https://gitter.im/crowfork/community?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge"><img src="https://badges.gitter.im/crowfork/community.svg" alt="Gitter"></a>
</p>

[![Build Status](https://travis-ci.com/mrozigor/crow.svg?branch=master)](https://travis-ci.com/mrozigor/crow)
[![Coverage Status](https://coveralls.io/repos/github/mrozigor/crow/badge.svg?branch=master)](https://coveralls.io/github/mrozigor/crow?branch=master)
[![Gitter](https://badges.gitter.im/crowfork/community.svg)](https://gitter.im/crowfork/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

## Description

Crow is a C++ microframework for running web services. It uses routing similar to Python's Flask which makes it easy to use. It is also extremely fast, beating multiple existing C++ frameworks as well as non C++ frameworks.

### Features
- Easy Routing (similar to flask).
- Type-safe Handlers.
- Blazingly fast (see [this benchmark](https://github.com/ipkn/crow-benchmark) and [this benchmark](https://github.com/guteksan/REST-CPP-benchmark)).
- Built in JSON support.
- [Mustache](http://mustache.github.io/) based templating library (`crow::mustache`).
- Header only library (single header file available).
- Middleware support for extensions.
- HTTP/1.1 and Websocket support.
- Multi-part request and response support.
- Uses modern C++ (11/14)

### Still in development
- [HTTP/2 support](https://github.com/crowcpp/crow/issues/8)

## Documentation
Available [here](https://crowcpp.github.io/crow).

## Examples

#### Hello World
```c++
#include "crow.h"

Expand All @@ -21,30 +49,8 @@ int main()
}
```

## 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)
- You can also use [json11](https://github.com/dropbox/json11) or [rapidjson](https://github.com/miloyip/rapidjson) for better speed or readability
- [Mustache](http://mustache.github.io/) based templating library (crow::mustache)
- Header only
- All-in-one header file available
- Middleware support
- Websocket support

## Still in development
- ~~Built-in ORM~~
- Check [sqlpp11](https://github.com/rbock/sqlpp11) if you want one.

## Examples

#### JSON Response
```c++
```cpp
CROW_ROUTE(app, "/json")
([]{
crow::json::wvalue x;
Expand All @@ -54,7 +60,7 @@ CROW_ROUTE(app, "/json")
```
#### Arguments
```c++
```cpp
CROW_ROUTE(app,"/hello/<int>")
([](int count){
if (count > 100)
Expand All @@ -65,7 +71,7 @@ CROW_ROUTE(app,"/hello/<int>")
});
```
Handler arguments type check at compile time
```c++
```cpp
// Compile error with message "Handler type is mismatched with URL paramters"
CROW_ROUTE(app,"/another/<int>")
([](int a, int b){
Expand All @@ -74,7 +80,7 @@ CROW_ROUTE(app,"/another/<int>")
```
#### Handling JSON Requests
```c++
```cpp
CROW_ROUTE(app, "/add_json")
.methods("POST"_method)
([](const crow::request& req){
Expand All @@ -88,47 +94,17 @@ CROW_ROUTE(app, "/add_json")
});
```

## How to Build

If you just want to use crow, generate `crow_all.h` (use script `scripts/merge_all.py`) and include it.

### Requirements

- C++ compiler with good C++14 support.
- Tested on g++-9.3 and clang-7.0, AMD64 (x86_64) and Arm64 v8
- boost 1.7 library.
- (optional) CMake to build tests and/or examples.
- (optional) Linking with tcmalloc/jemalloc is recommended for speed.

### 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
More examples can be found [here](https://github.com/crowcpp/crow/tree/master/examples).

#### Ubuntu
sudo apt-get install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so
## Setting Up / Building
Available [here](https://crowcpp.github.io/crow/getting_started/setup).

#### OSX
brew install boost google-perftools

### Attributions

Crow uses the following libraries.

http-parser
http-parser (used for converting http strings to crow::request objects)

https://github.com/nodejs/http-parser

Expand Down Expand Up @@ -157,7 +133,7 @@ Crow uses the following libraries.
IN THE SOFTWARE.


qs_parse
qs_parse (used for reading query string parameters)

https://github.com/bartgrantham/qs_parse

Expand All @@ -172,7 +148,7 @@ Crow uses the following libraries.
all copies or substantial portions of the Software.


TinySHA1
TinySHA1 (used during the websocket handshake, not for security)

https://github.com/mohaps/TinySHA1

Expand Down

0 comments on commit 6f31e59

Please sign in to comment.