-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: build a simple cmake project * chore: add some .gitignore files * docs: add README * build: add Makefile with CMake commands * chore: update .gitignore * build: follow Conan 2.0 simple CMake project tutorial * build: use conanfile.py instead of conanfile.txt * docs: add conan command to README * build: change c build to c++ build * build: switch import from zlib to Crow * docs: update README with correct cmake command * feat: create hello world application https://crowcpp.org/master/getting_started/your_first_application/ * docs: update set up instructions * feat: add success response to endpoint * docs: changes to readme * docs: update README.md --------- Co-authored-by: ni-jessica <[email protected]> Co-authored-by: stellaljung <[email protected]>
- Loading branch information
1 parent
f19306e
commit ad53f73
Showing
6 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.27) | ||
project(backend) | ||
|
||
find_package(Crow REQUIRED) | ||
|
||
add_executable(${PROJECT_NAME} src/main.cpp) | ||
target_link_libraries(${PROJECT_NAME} Crow::Crow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Backend | ||
|
||
## Configuration | ||
|
||
In `/backend`, install conan: | ||
|
||
```bash | ||
brew install conan cmake | ||
conan install . --output-folder=build --build=missing | ||
``` | ||
|
||
Set up the `/build/` folder: | ||
|
||
```bash | ||
mkdir build && cd build | ||
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release | ||
cmake --build . | ||
``` | ||
|
||
From `/backend`, start the server: | ||
|
||
```bash | ||
cd build && ./backend | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from conan import ConanFile | ||
|
||
|
||
class BackendRecipe(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeToolchain", "CMakeDeps" | ||
|
||
def requirements(self): | ||
self.requires("crowcpp-crow/1.0+5") | ||
|
||
def build_requirements(self): | ||
self.tool_requires("cmake/3.22.6") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "crow.h" | ||
|
||
int main(void) { | ||
// delcare crow application | ||
crow::SimpleApp app; | ||
|
||
// define endpoint at the root directory | ||
CROW_ROUTE(app, "/")([](){ | ||
crow::json::wvalue response; | ||
response["status"] = "success"; | ||
return response; | ||
}); | ||
|
||
// set the port, set the app to run on multiple threads, and run the app | ||
app.port(18080).multithreaded().run(); | ||
} |