Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CROW_MAIN docs and script #118

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/getting_started/your_first_application.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
This page shows how you can get started with a simple hello world application.

##1. Include
Starting with an empty `main.cpp` file, add `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file.
Starting with an empty `main.cpp` file, add `#!cpp #CROW_MAIN` then `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file.

!!! note

If you're using multiple C++ source files make sure to have `#CROW_MAIN` defined only in your main source file.

##2. App declaration
Next Create a `main()` and declare a `#!cpp crow::SimpleApp` inside, your code should look like this
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If you want crow to run in a subdirectory (such as `domain.abc/crow`) you can us

!!! note

If you're using an Arch Linux based OS. You will have to access `/etc/httpd/conf/httpd.conf` to enable modules and change configuration
If you're using an Arch Linux based OS. You will have to access `/etc/httpd/conf/httpd.conf` to enable modules and change configuration.

##Nginx

Expand Down
10 changes: 9 additions & 1 deletion scripts/nginx_mime2cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def main():
"#include <string>",
"",
"namespace crow {",
"",
"#ifdef CROW_MAIN"
tabspace + "std::unordered_map<std::string, std::string> mime_types {"])

with open(file_path, "r") as mtfile:
Expand All @@ -40,7 +42,13 @@ def main():
outLines.extend(mime_line_to_cpp(splitLine))

outLines[-1] = outLines[-1][:-1]
outLines.extend([tabspace + "};", "}"])
outLines.extend([
tabspace + "};",
"#else",
"extern std::unordered_map<std::string, std::string> mime_types;",
"#endif",
"}"
])

with open(output_path, "w") as mtcppfile:
mtcppfile.writelines(x + '\n' for x in outLines)
Expand Down