⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Wt
All Projects
Wt
Overview
Activity
Roadmap
Issues
Wiki
Forums
Download (1.23 KB)
Bug #11423
ยป resource_internalpath.cpp
Roel Standaert, 03/10/2023 11:09 AM
#include
<Wt/WApplication.h>
#include
<Wt/WContainerWidget.h>
#include
<Wt/WResource.h>
#include
<Wt/WServer.h>
#include
<Wt/WText.h>
#include
<Wt/Http/Response.h>
#include
<memory>
namespace
{
class
Application
final
:
public
Wt
::
WApplication
{
public:
explicit
Application
(
const
Wt
::
WEnvironment
&
env
);
};
Application
::
Application
(
const
Wt
::
WEnvironment
&
env
)
:
Wt
::
WApplication
(
env
)
{
root
()
->
addNew
<
Wt
::
WText
>
(
Wt
::
utf8
(
"Hello"
));
}
std
::
unique_ptr
<
Wt
::
WApplication
>
createApplication
(
const
Wt
::
WEnvironment
&
env
)
{
return
std
::
make_unique
<
Application
>
(
env
);
}
class
Resource
final
:
public
Wt
::
WResource
{
public:
void
handleRequest
(
const
Wt
::
Http
::
Request
&
request
,
Wt
::
Http
::
Response
&
response
)
override
;
};
void
Resource
::
handleRequest
([[
maybe_unused
]]
const
Wt
::
Http
::
Request
&
request
,
Wt
::
Http
::
Response
&
response
)
{
response
.
setMimeType
(
"text/plain"
);
response
.
out
()
<<
"API"
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
Resource
resource
;
Wt
::
WServer
server
(
argc
,
argv
,
WTHTTP_CONFIGURATION
);
server
.
addEntryPoint
(
Wt
::
EntryPointType
::
Application
,
createApplication
);
server
.
addResource
(
&
resource
,
"api"
);
server
.
run
();
}
(1-1/1)
Loading...