Hi Koen!

On Thu, Jul 2, 2015 at 7:37 AM, Koen Deforche <[email protected]> wrote:
> Hey,
>
> The wthttpd is also a simple web server, serving static files from inside
> it's docroot.

Okay, I think I have this working.

Just to confirm, is the following the minimal wthttpd server?

   #include <Wt/WApplication>
   #include <Wt/WEnvironment>

   using namespace Wt;

   WApplication *createApplication(const WEnvironment& env) {
     return new WApplication (env);
   }

   int main (int argc, char **argv) {
     return WRun (argc, argv, &createApplication);
   }

Note, I do not derive from WApplication -- I just instantiate a plain
WApplication and pass it to WRun.  (Of course my app has no
dynamic content, but I guess the WApplication is the wthttpd server
and the call to WRun starts it up.  Is this correct?

Is this the bare-bones but "right" way to use wthttpd as a static
content web server?

I then run the server as follows:

   minimal_wt_server --http-address=0.0.0.0 --http-port=80
--deploy-path=/dummy --docroot=.

> The simplest way to serve static contents is to put it into
> the docroot.

If I then put a simple "index.html" file in the working directory of
minimal_wt_server (This should be the docroot directory.) then a
call to the url:

   http://localhost/

shows the contents of index.html.

If I had set "--deploy-path=/" (rather than "--deploy-path=/dummy")
then "http://localhost/"; would have shown the "blank" web page of
the "empty" WApplication app.  (To see index.html I would have to
use "http://localhost/index.html";.)

Is this all correct?

> You will need to implement a main() function to instantiate the server.

Just to confirm, main needs to call WRun with a pointer to a function
that returns a (pointer to a) WApplication object.  (That is, there is not,
for example, some function call such as WApplication::start_wthttpd()
that starts an "empty" wthttpd server.)  Is this correct?

> From your use-case, it sounds logical and totally sensible to host the
> static pages inside the same wthttpd that also serves your dynamic content.

Yes, thanks.  That is the general idea I am thinking of.

> Koen

Sorry for these naive and detailed questions, but this is all new to me.


Thanks.


K. Frank


> 2015-06-29 15:41 GMT+02:00 K. Frank <[email protected]>:
>>
>> Hello List!
>>
>> I am new to Wt (and to web programming in general).  I have built a
>> few very simple Wt applications and hosted them with wthttpd.
>>
>> What is the easiest (or most practical) way to use wthttpd to serve a
>> single html web page?  If this can't be done reasonably, what would be
>> the simplest way to wrap the html file (with minor tweaks, if necessary)
>> in a Wt application and then host it with wthttpd?
>>
>> More generally, let's say that I would like my home page to be a plain
>> html web page that has links to Wt web pages / applications.  Would
>> it be practical to host such a scheme with wthttpd, and, if so, what
>> would be the best way to do so?
>>
>> (Side question:  Could anyone recommend a basic, lightweight html
>> editor?)
>>
>> Thanks.
>>
>> K. Frank

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to