fork download
  1. #include <iostream>
  2. #include <cstdlib> // สำหรับ system()
  3. #include "httplib.h" // ดาวน์โหลดจาก: https://g...content-available-to-author-only...b.com/yhirose/cpp-httplib
  4.  
  5. int main() {
  6. httplib::Server svr;
  7.  
  8. svr.Get("/open", [](const httplib::Request& req, httplib::Response& res) {
  9. // ตัวอย่าง: เปิด Notepad (Windows)
  10. system("start notepad");
  11. res.set_content("เปิดโปรแกรมเรียบร้อย!", "text/plain");
  12. });
  13.  
  14. std::cout << "Server run ที่ http://<your-ip>:8080/open\n";
  15. svr.listen("0.0.0.0", 8080); // ให้เชื่อมได้จากอุปกรณ์อื่น
  16. }
  17.  
Success #stdin #stdout 0.04s 25668KB
stdin
Standard input is empty
stdout
#include <iostream>
#include <cstdlib> // สำหรับ system()
#include "httplib.h" // ดาวน์โหลดจาก: https://g...content-available-to-author-only...b.com/yhirose/cpp-httplib

int main() {
    httplib::Server svr;

    svr.Get("/open", [](const httplib::Request& req, httplib::Response& res) {
        // ตัวอย่าง: เปิด Notepad (Windows)
        system("start notepad");
        res.set_content("เปิดโปรแกรมเรียบร้อย!", "text/plain");
    });

    std::cout << "Server run ที่ http://<your-ip>:8080/open\n";
    svr.listen("0.0.0.0", 8080); // ให้เชื่อมได้จากอุปกรณ์อื่น
}