This commit is contained in:
2026-07-20 19:24:50 +10:00
parent 6241824960
commit 94b5365a1c
2 changed files with 20 additions and 11 deletions

View File

@@ -104,17 +104,19 @@ int main() {
});
svr.Post("/like", [&database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
std::string username = request.get_param_value("username");
std::string password = request.get_param_value("password");
std::string post = request.get_param_value("post");
std::lock_guard<std::mutex> lock(data_mutex);
try {
std::string username = request.form.get_field("username");
std::string password = request.form.get_field("password");
std::string post = request.form.get_field("post");
std::lock_guard<std::mutex> lock(data_mutex);
uint64_t postNum = std::stoull(post);
database.addLike(postNum, 0);
} catch (const std::runtime_error& e) {
response.set_content("<p>there was an error :( it is: " + std::string(e.what()) + "</p>", "text/html");
} catch (const std::exception& e) {
response.set_content("<p>there was an error :( it is: " + std::string(e.what()) + "</p>", "text/html");
}
});