#include "TessesFramework/TessesFramework.hpp" #include using namespace Tesses::Framework; using namespace Tesses::Framework::Streams; using namespace Tesses::Framework::Http; using namespace Tesses::Framework::Filesystem; VFS* vfs; int main(int argc, char** argv) { TF_InitWithConsole(); vfs = new SubdirFilesystem(&LocalFS,Tesses::Framework::Filesystem::VFSPath::GetAbsoluteCurrentDirectory(),false); CallbackServer cb([](ServerContext& ctx)->bool{ if(ctx.path == "/") { ctx.WithMimeType("text/html") .SendText( "" "" "AnonyDump" "" "

AnonyDump

" "Files" "
" "" "" "
" "" "" ); return true; } else if(ctx.path == "/upload") { if(ctx.NeedToParseFormData()) { ctx.ParseFormData([](std::string mime, std::string filename,std::string name)->Stream* { if(name != "file") return nullptr; VFSPath path("/"+filename); auto strm = vfs->OpenFile(path,"wb"); return strm; }); ctx.WithMimeType("text/html") .SendText( "" "" "AnonyDump - Uploaded successfully" "" "

Uploaded successfully

" "Back" "" "" "" ); return true; } else { ctx.statusCode= Tesses::Framework::Http::BadRequest; ctx.WithMimeType("text/html") .SendText( "" "" "AnonyDump - Error: Must contain multipart and POST" "" "

Error: Must contain multipart and POST

" "Back" "" "" "" ); } } return false; }); Tesses::Framework::Http::MountableServer mountable(cb); mountable.Mount("/files/",new FileServer(vfs,true,true,false),true); HttpServer srv(4985,mountable); srv.StartAccepting(); TF_RunEventLoop(); TF_Quit(); return 0; }