Untitled

 avatar
unknown
plain_text
2 months ago
871 B
3
Indexable
#include "httplib.h"
#include <fstream>
#include <sstream>

std::string read_file(const std::string& file_path) {
    std::ifstream file(file_path);
    if (!file.is_open()) {
        return "";
    }

    std::stringstream buffer;
    buffer << file.rdbuf();
    return buffer.str();
}

int main() {
    httplib::Server svr;

    // ZeroSSL doğrulama dosyası için özel route
    svr.Get("/.well-known/pki-validation/DEE7E5324E8B883BFDBEFC7463FB61BD.txt", [](const httplib::Request& req, httplib::Response& res) {
        std::string content = read_file("./.well-known/pki-validation/DEE7E5324E8B883BFDBEFC7463FB61BD.txt");
        if (!content.empty()) {
            res.set_content(content, "text/plain");
        } else {
            res.status = 404; // Dosya bulunamadı
        }
    });

    svr.listen("0.0.0.0", 80); // Sunucuyu 80 numaralı portta başlat
}
Leave a Comment