mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
fixed warnings in documentation
This commit is contained in:
parent
8f127179ce
commit
528c3e0cf8
@ -1,7 +1,7 @@
|
||||
Hello World is a good start, but what if you want something a bit more fancy.. Something like an HTML document saying "Hello World". If that's what you want, follow along:
|
||||
|
||||
## Basic Webpage
|
||||
Let's start our webpage with.. well.. a webpage. But before we create a webpage we need to place it somewhere Crow recognizes, for now this directory is going to be called `templates`, but we can [change it later](../../guides/templating/#page).
|
||||
Let's start our webpage with.. well.. a webpage. But before we create a webpage we need to place it somewhere Crow recognizes, for now this directory is going to be called `templates`, but we can [change it later](../guides/templating.md#page).
|
||||
|
||||
Once our `templates` folder is created, we can create our HTML document inside it, let's call it `fancypage.html`.
|
||||
|
||||
@ -80,13 +80,17 @@ Once the code is done compiling, if we call `http://localhost:18080/` we get our
|
||||
|
||||
!!! note
|
||||
|
||||
Compilation instructions are available for [Linux](../setup/linux#compiling-your-project), [MacOS](../setup/macos#compiling-using-a-compiler-directly), and [Windows](../setup/windows#getting-and-compiling-crow)
|
||||
Compilation instructions are available for
|
||||
[Linux](setup/linux.md#compiling-your-project),
|
||||
[MacOS](setup/macos.md#compiling-using-a-compiler-directly),
|
||||
and
|
||||
[Windows](setup/windows.md#getting-and-compiling-crow)
|
||||
|
||||
|
||||
## Template Webpage with a variable
|
||||
But we can make things even more exciting, we can greet a user by their name instead!!
|
||||
|
||||
Let's start with our webpage, and modify it with a little bit of [mustache](../../guides/templating) syntax:
|
||||
Let's start with our webpage, and modify it with a little bit of [mustache](../guides/templating.md) syntax:
|
||||
``` html title="templates/fancypage.html" hl_lines="4"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@ -121,9 +125,9 @@ int main()
|
||||
|
||||
1. We are adding a `string` variable to the URL and a counterpart (`std::string name`) to our route - this can be anything the user wants.
|
||||
2. We are using `load()` instead of `load_text()` since we have an actual variable now.
|
||||
3. We are creating a new [context](../../guides/templating/#context) containing the `person` variable from our template and the `name` we got from the URL.
|
||||
3. We are creating a new [context](../guides/templating.md#context) containing the `person` variable from our template and the `name` we got from the URL.
|
||||
4. We are using `render(ctx)` to apply our context to the template.
|
||||
|
||||
Now (after compiling the code and running the executable a second time) calling `http://localhost:18080/Bob` should return a webpage containing "Hello Bob!". **We did it!**
|
||||
|
||||
For more details on templates and HTML pages in Crow please go [here](../../guides/templating/)
|
||||
For more details on templates and HTML pages in Crow please go [here](../guides/templating.md)
|
||||
|
@ -16,7 +16,7 @@ int main()
|
||||
}
|
||||
```
|
||||
The App (or SimpleApp) class organizes all the different parts of Crow and provides the developer (you) a simple interface to interact with these parts.
|
||||
For more information, please go [here](../../guides/app).
|
||||
For more information, please go [here](../guides/app.md).
|
||||
|
||||
## 3. Adding routes
|
||||
Once you have your app, the next step is to add routes (or endpoints). You can do so with the `CROW_ROUTE` macro.
|
||||
@ -25,7 +25,7 @@ CROW_ROUTE(app, "/")([](){
|
||||
return "Hello world";
|
||||
});
|
||||
```
|
||||
For more details on routes, please go [here](../../guides/routes).
|
||||
For more details on routes, please go [here](../guides/routes.md).
|
||||
|
||||
## 4. Running the app
|
||||
Once you're happy with how you defined all your routes, you're going to want to instruct Crow to run your app. This is done using the `run()` method.
|
||||
@ -56,6 +56,9 @@ int main()
|
||||
}
|
||||
```
|
||||
|
||||
You then need to compile your code on your [Linux](../setup/linux#compiling-your-project), [MacOS](../setup/macos#compiling-using-a-compiler-directly), or [Windows](../setup/windows#getting-and-compiling-crow) machine
|
||||
You then need to compile your code on your
|
||||
[Linux](setup/linux.md#compiling-your-project),
|
||||
[MacOS](setup/macos.md#compiling-using-a-compiler-directly), or
|
||||
[Windows](setup/windows.md#getting-and-compiling-crow) machine
|
||||
|
||||
After building your `.cpp` file and running the resulting executable, you should be able to access your endpoint at [http://localhost:18080](http://localhost:18080). Opening this URL in your browser will show a white screen with "Hello world" typed on it.
|
||||
|
@ -34,5 +34,5 @@ app.bindaddr("192.168.1.2")
|
||||
|
||||
<br><br>
|
||||
|
||||
For more info on middlewares, check out [this page](../middleware).<br><br>
|
||||
For more info on middlewares, check out [this page](middleware.md).<br><br>
|
||||
For more info on what functions are available to a Crow app, go [here](../reference/classcrow_1_1_crow.html).
|
||||
|
@ -1,6 +1,6 @@
|
||||
Crow contains some middlewares that are ready to be used in your application.
|
||||
<br>
|
||||
Make sure you understand how to enable and use [middleware](../middleware/).
|
||||
Make sure you understand how to enable and use [middleware](middleware.md).
|
||||
|
||||
## Sessions
|
||||
Include: `crow/middlewares/session.h` <br>
|
||||
|
@ -41,7 +41,7 @@ Additionally, a `wvalue` can be initialized as an object using an initializer li
|
||||
|
||||
An object type `wvalue` uses `std::unordered_map` by default, if you want to have your returned `wvalue` key value pairs be sorted (using `std::map`) you can add `#!cpp #define CROW_JSON_USE_MAP` to the top of your program.<br><br>
|
||||
|
||||
A JSON `wvalue` can be returned directly inside a route handler, this will cause the `content-type` header to automatically be set to `Application/json` and the JSON value will be converted to string and placed in the response body. For more information go to [Routes](../routes).<br><br>
|
||||
A JSON `wvalue` can be returned directly inside a route handler, this will cause the `content-type` header to automatically be set to `Application/json` and the JSON value will be converted to string and placed in the response body. For more information go to [Routes](routes.md).<br><br>
|
||||
|
||||
For more info on write values go [here](../reference/classcrow_1_1json_1_1wvalue.html).
|
||||
|
||||
|
@ -16,12 +16,12 @@ There are 2 components of a mustache template implementation:
|
||||
### Page
|
||||
The HTML page (including the mustache tags). It is usually loaded into `crow::mustache::template_t`. It needs to be placed in the *templates directory* which should be directly inside the current working directory of the crow executable.<br><br>
|
||||
|
||||
The templates directory is usually called `templates`, but can be adjusted per Route (via `crow::mustache::set_base("new_templates_directory")`), per [Blueprint](../blueprints), or globally (via `crow::mustache::set_global_base("new_templates_directory"")`).<br><br>
|
||||
The templates directory is usually called `templates`, but can be adjusted per Route (via `crow::mustache::set_base("new_templates_directory")`), per [Blueprint](blueprints.md), or globally (via `crow::mustache::set_global_base("new_templates_directory"")`).<br><br>
|
||||
|
||||
For more information on how to formulate a template, see [this mustache manual](http://mustache.github.io/mustache.5.html).
|
||||
|
||||
### Context
|
||||
A JSON object containing the tags as keys and their values. `crow::mustache::context` is actually a [crow::json::wvalue](../json#wvalue).<br><br>
|
||||
A JSON object containing the tags as keys and their values. `crow::mustache::context` is actually a [crow::json::wvalue](json.md#wvalue).<br><br>
|
||||
|
||||
!!! note
|
||||
|
||||
|
@ -43,8 +43,8 @@ markdown_extensions:
|
||||
- pymdownx.keys
|
||||
- attr_list
|
||||
- pymdownx.emoji:
|
||||
emoji_index: !!python/name:materialx.emoji.twemoji
|
||||
emoji_generator: !!python/name:materialx.emoji.to_svg
|
||||
emoji_index: !!python/name:material.extensions.emoji.twemoji
|
||||
emoji_generator: !!python/name:material.extensions.emoji.to_svg
|
||||
|
||||
|
||||
nav:
|
||||
|
Loading…
Reference in New Issue
Block a user