From 5079d3406a02361134639a5c63ab9e48955a38d6 Mon Sep 17 00:00:00 2001 From: yhirose Date: Fri, 17 Jul 2015 21:52:46 -0400 Subject: [PATCH] Added XMLHttpRequest Level2 support. --- lint/playground/main.cc | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/lint/playground/main.cc b/lint/playground/main.cc index 9f857e4..b808b56 100644 --- a/lint/playground/main.cc +++ b/lint/playground/main.cc @@ -7,18 +7,6 @@ using namespace httplib; using namespace std; -void open_url(const char* url) -{ - string cmd; -#ifdef _MSC_VER - cmd += "start "; -#else - cmd += "open "; -#endif - cmd += url; - system(cmd.c_str()); -} - function makeJSONFormatter(string& json) { auto init = make_shared(true); @@ -86,11 +74,10 @@ int main(void) } json += "}"; - res.set_content(json, "application/json"); - }); + res.set_header("Access-Control-Allow-Origin", "*"); + res.set_header("Access-Control-Allow-Methods", "POST"); - svr.get("/stop", [&](const Request& req, Response& res) { - svr.stop(); + res.set_content(json, "application/json"); }); svr.set_error_handler([](const Request& req, Response& res) { @@ -100,8 +87,6 @@ int main(void) res.set_content(buf, "text/html"); }); - open_url("http://localhost:1234"); - svr.listen("localhost", 1234); return 0;