sic/src/UltraSimpleStaticFileHandle...

42 lines
895 B
C++
Raw Normal View History

2014-01-18 14:48:52 +01:00
#include <string>
#include "UltraSimpleStaticFileHandler.H"
#include <mongoose.h>
2014-01-17 23:47:14 +01:00
static const char * hello_world_html = u8R"HERE(
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title></title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<h1 id="sharing-is-caring">Sharing is caring</h1>
<p>Hello World!</p>
<h2 id="it-works">It works</h2>
<p>It seems like a working page has been served</p>
</body>
</html>)HERE";
class UltraSimpleStaticFileHandler : StaticFileHandler
{
public:
int answer_pathreq(const char * const path, struct mg_connection *conn)
{
mg_printf(conn, "HTTP/1.0 200 OK\r\n"
"Content-Length: %d\r\n"
"Content-Type: text/html\r\n\r\n%s",
hello_world_html.size(),
hello_world_html.c_str());
return 0;
}
2014-01-17 23:47:14 +01:00
};