Vibe D Examples

infinityplusb brian at infinityplusb.com
Thu Jun 21 00:13:52 UTC 2018


On Wednesday, 20 June 2018 at 22:46:16 UTC, infinityplusb wrote:
> I'm trying to reacquaint myself with D, and Vibe in particular.
> I notice that some of my previous working apps now don't work.
>
> While going through the tour.dlang page, I can't seem to get 
> any of those sample apps working either. Nor do the apps in 
> Vibe's github page appear to be up to date with the recent 
> changes.
>
> Are there some current, simple, working examples that I could 
> plagiarise to get something going?
>
> TIA
> Brian

Nevermind. Simple case of RTFM ...

-- source/app.d
import vibe.d;

void main()
{
     auto settings = new HTTPServerSettings("127.0.0.1");
     settings.port = 48081;

	auto router = new URLRouter ;
	router
		.get("/", &homeScreen)
	;

     listenHTTP(settings, router);
     runApplication();
}

void homeScreen(HTTPServerRequest req, HTTPServerResponse res)
{
// 	res.writeBody("Hello again Vibe.d: ");
	res.render!("home.dt") ;
}

-- views/home.dt
doctype html5

head
     title Hello World

body
     p Hello template vibe


More information about the Digitalmars-d-learn mailing list