June 25, 2017
Am 25.06.2017 um 00:16 schrieb Wulfklaue:
> On Saturday, 24 June 2017 at 20:29:23 UTC, Sönke Ludwig wrote:
>> /++ dub.sdl
>>     name "webserver"
>>     dependency "vibe-d:http" version="~>0.7.31"
>> +/
>> module main;
>>
>> import vibe.core.core;
>> import vibe.http.fileserver;
>> import vibe.http.server;
>>
>> void main()
>> {
>>     listenHTTP(new HTTPServerSettings, serveStaticFiles("./"));
>>     runApplication();
>> }
>>
>> $ dub main.d
>>
>> Although of course vibe.d is not included with the compiler, this
>> works out of the box for a standard DMD/LDC installation.
>
> No it does not...
>

I've got to admit that I typed this from the top of my head without actually running it, and of course I got the syntax wrong. The first line must be "/+ dub.sdl:", with a colon at the end.

The error message is off, because, after a refactoring, the colon that should end the first line is also accepted on any later line within the comment. I'll prepare a PR to fix this.
June 25, 2017
Am 25.06.2017 um 00:18 schrieb Timon Gehr:
> $ cat main.d
> /++ dub.sdl: <--  colon missing here
> (...)
>
> What am I doing wrong?

I forgot a colon at the end of the first line. With that it *actually* works now.
June 24, 2017
On Saturday, 24 June 2017 at 22:18:29 UTC, Timon Gehr wrote:
> $ cat main.d
> /++ dub.sdl
>     name "webserver"
>     dependency "vibe-d:http" version="~>0.7.31"
> +/
> module main;
>
> import vibe.core.core;
> import vibe.http.fileserver;
> import vibe.http.server;
>
> void main()
> {
>     listenHTTP(new HTTPServerSettings, serveStaticFiles("./"));
>     runApplication();
> }
> $ dub main.d
> readPackageRecipe called with filename with unknown extension: + dub.sdl
>     name "webserver"
>     dependency "vibe-d
>
> What am I doing wrong?

See the post above yours. Attempt 3:

Run:

* CMD> dub init projectname
* Enter sdl for your project file
* Enter the rest like you want
* CMD> cd projectname
* Edit the dub.sdl file and add the "dependency "vibe-d:http" version="~>0.7.31"" at the end.
* CMD> cd src
* Now edit the app.d file and replace the code with. No need for the /++ stuff.

> module main;
>
> import vibe.core.core;
> import vibe.http.fileserver;
> import vibe.http.server;
>
> void main()
> {
>     listenHTTP(new HTTPServerSettings, serveStaticFiles("./"));
>     runApplication();
> }

* Go back to your projectname folder and run dub
* CMD> dub
* And with some luck it will run correctly.


And thank for proving my point that some do not understand that something they consider simply, is not always simply for people doing it the first time.

Now frankly, if the whole /++ dub.sdl +/ actually worked as a file based dependency, now that will be a interesting feature ;)
June 25, 2017
On 25.06.2017 00:34, Sönke Ludwig wrote:
> Am 25.06.2017 um 00:18 schrieb Timon Gehr:
>> $ cat main.d
>> /++ dub.sdl: <--  colon missing here
>> (...)
>>
>> What am I doing wrong?
> 
> I forgot a colon at the end of the first line. With that it *actually* works now.

$ dub main.d
Failed to listen on :::80
Failed to listen on 0.0.0.0:80
object.Exception@../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d(1698): Failed to listen for incoming HTTP connections on any of the supplied interfaces.
----------------
June 24, 2017
On Saturday, 24 June 2017 at 22:16:11 UTC, Wulfklaue wrote:

> Attempt 1:
> Attempt 2:
> Attempt 3:
> Attempt 4:
> Attempt 5:
> =========

Almost forgot to mention, this was done under Windows ( where the inline does not work ). It works under Linux but that is a different issue.
June 24, 2017
On Saturday, 24 June 2017 at 23:00:59 UTC, Timon Gehr wrote:
> $ dub main.d
> Failed to listen on :::80
> Failed to listen on 0.0.0.0:80
> object.Exception@../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d(1698): Failed to listen for incoming HTTP connections on any of the supplied interfaces.
> ----------------

You probably already have a server active on port 80. That is why it fails. You need to use a different port or temporary turn off the service that is using port 80 currently.
June 24, 2017
On Saturday, 24 June 2017 at 23:00:59 UTC, Timon Gehr wrote:
> Failed to listen on :::80

Listening on port 80 requires root anyway. That's why like my cgi.d uses 8085 - anything over 1024 can be listened by any user (and is less likely to have an existing program on it)

June 25, 2017
On 25.06.2017 01:03, Wulfklaue wrote:
> On Saturday, 24 June 2017 at 23:00:59 UTC, Timon Gehr wrote:
>> $ dub main.d
>> Failed to listen on :::80
>> Failed to listen on 0.0.0.0:80
>> object.Exception@../../.dub/packages/vibe-d-0.7.31/vibe-d/source/vibe/http/server.d(1698): Failed to listen for incoming HTTP connections on any of the supplied interfaces.
>> ----------------
> 
> You probably already have a server active on port 80. That is why it fails. You need to use a different port or temporary turn off the service that is using port 80 currently.

$ sudo netstat -tulpn | grep :80
$
June 25, 2017
On 25.06.2017 01:09, Adam D. Ruppe wrote:
> On Saturday, 24 June 2017 at 23:00:59 UTC, Timon Gehr wrote:
>> Failed to listen on :::80
> 
> Listening on port 80 requires root anyway. That's why like my cgi.d uses 8085 - anything over 1024 can be listened by any user (and is less likely to have an existing program on it)
> 

Thanks! I guessed as much, but I don't have a setup where root can build the code. (And I don't see why it should.)
June 24, 2017
On Saturday, 24 June 2017 at 19:22:48 UTC, Ecstatic Coder wrote:
> Two lines of code, that's all that's needed to serve an entire website, with all sorts of files (html, css, js, jpg, png, etc) located in plenty of directories.

Fun fact: I actually do *not* have code that does that in one line. With my cgi.d, you'd have to roll your own with std.file and the cgi params or something. It isn't hard, but I didn't provide my own function since it is useless to me - serving static files is done brilliantly well by your production web server, so why not just use it?!


Anyway, my point is that anybody can put a few examples in the stdlib and say "look at how easy this is!", but the real question is how easy it is to do something that the example writers didn't think of. That's why I want to promote decentralization - with a lot of people owning their own projects, you are more likely to find what you need.

Just at the same time, you're right that locating, evaluating, and actually using these things is a hassle. (In fact, I find in most languages that libraries are NOT worth the hassle and I avoid using them!)


So that's why the balance I want to get is one where the projects are developed individually, but particularly useful/popular ones are bundled by the central maintainers... or ranked by the lib repo website (code.dlang.org or otherwise) and trivially downloaded on demand. I also want tutorials with a lot of fully working examples available and easily discovered to show how to use these.

We're currently OK at this, but it could be better.

> Which is very sad, because webserver development is a domain where D can be a perfect contender to Go, Java and C#, and not everybody is willing to use a full framework just to have the same functionalities as these two simple lines of Go code.

The real WTF is you'd use two lines of Go code when you can just copy your files into /var/www/htdocs and let Apache do it for you.