You probably know that I don't use dub, but if you do, that's an option, just add the arsd-official:cgi (and other subpackages) to your dependencies list. If not, the easiest way to get started is to git clone the arsd repo from github to your project directory.
with dub
without dub
$ git clone https://github.com/adamdruppe/arsd.git
Make a source file server.d with these contents:
import arsd.cgi; void handler(Cgi cgi) { cgi.write("Hello, world!", true); } mixin GenericMain!handler;
Then, compile and run the server:
with dub
$ dub build $ dub run -- --port 8080
without dub
$ dmd -i -version=embedded_httpd_hybrid server $ ./server --port 8080
And finally, go to http://localhost:8080/ in your browser and you should be greeted with the hello message!
FIXME: "that didn't happen"
Now that we know the basics are set up, let's skip ahead to the end so you can see what we are building toward in this tutorial. Don't worry if you don't understand any of this, we'll come back to it all.
The program will provide a website with information about a local bus system. It will provide textual information, maps, a trip planner, and an api, with the option of sending email reminders.
Many of the oldest modules in this repo (along with some of the new ones) were written so I could easily replace PHP with D for writing web applications with server-side HTML rendering, JSON apis, etc.
However, due to my general philosophy of providing helper code rather than a pre-baked framework, it has historically not been obvious to other people how we can use these modules to make a website. While I still believe in providing code that YOU decide how you want to use it, the purpose of this document is to give you one possible cohesive vision and a path you can follow to get productive making websites in D with my arsd libraries.