---
title: "Create a HTTP Server"
---

> Documentation Index
> Fetch the complete documentation index at: https://openarkstudio.github.io/arknet/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a HTTP Server

Configure a C++20 application using [Installation](/arknet/get-started/installation). Start the server before running the [matching client](/arknet/features/http/client).

## HTTP Echo Server

Use the `arknet::arknet` interface target in a C++20 application following the
[build guide](/arknet/get-started/installation). Build the server and client blocks as separate
executables. Start the server first, then run the client in another terminal.
Press Enter in the server terminal to stop it. Plain HTTP does not require TLS.

```cpp
#include <iostream>
#include <utility>

#include <arknet/http/http_server.hpp>

int main()
{
    arknet::http_server server;
    server.bind_recv([](auto& session, arknet::http::request<arknet::http::string_body>& request)
    {
        arknet::http::response<arknet::http::string_body> response(
            arknet::http::status::ok, request.version());
        response.keep_alive(request.keep_alive());
        response.set(arknet::http::field::content_type, "text/plain");
        response.body() = request.body();
        response.prepare_payload();
        session->async_send(std::move(response));
    });
    if (!server.start("127.0.0.1", 8080))
    {
        std::cerr << arknet::get_last_error().message() << '\n';
        return 1;
    }
    std::cout << "HTTP listening on http://127.0.0.1:8080/echo\n";
    std::cin.get();
    server.stop();
}
```


[Configuration and advanced usage](/arknet/features/http/configuration) · [Performance](/arknet/features/http/performance)

Source: https://openarkstudio.github.io/arknet/features/http/server/index.mdx
