Main.cpp
- #ifndef _MAIN_H
- #define _MAIN_H
- #include <WebToolkit.h>
- class HelloWorld:public IHttpRequestHandler
- {
- private:
- Server server;
- public:
- HelloWorld();
- void Run();
- void Handle(HttpRequest* request,HttpResponse* response);
- };
- #endif
-. ( Windows — 29 ), . .
- #include "Main.h"
- HelloWorld::HelloWorld():server(8080,"0.0.0.0")
- {
- server.RegisterHandler(this);
- }
- void HelloWorld::Run()
- {
- server.Run();
- }
- void HelloWorld::Handle(HttpRequest* request,HttpResponse* response)
- {
- response->Write("<html><body><h1>Hello, world!</h1></body></html>");
- }
- int main()
- {
- try
- {
- HelloWorld app;
- app.Run();
- }
- catch(exception& e)
- {
- cout<<e.what()<<endl;
- }
- }
Source: https://habr.com/ru/post/61563/
All Articles