#include "Request.h" #include "Response.h" #include "Util.h" #include "json.hpp" #include #include #include "windows.h" using namespace std; using json = nlohmann::json; const string docroot = "D:\\Bitnami\\wampstack-5.6.31-0\\apache2\\htdocs\\"; int main() { Request req; Response res; json j; auto jsonfail=[&](int errcode,const std::string& errmsg) { j["success"]=0; j["errcode"]=errcode; j["errmsg"]=errmsg; }; do { if(req.requestMethod!="POST") { jsonfail(1,"Request Method Not Supported"); break; } if(req.post.find("code")==req.post.end() || req.post.find("title")==req.post.end() ) { jsonfail(2,"Missing Parameters"); break; } string code=req.post["code"]; string title=req.post["title"]; string html; ifstream ifs("paste_template.txt"); if(!ifs) { jsonfail(3,"Failed to read template."); break; } string temp; while(getline(ifs,temp)) { html.append(temp); } int len=code.size(); ostringstream ostr; for(int i=0;i') { ostr<<">"; } else { ostr<