How to setup D language with Apache httpd cgi?
bachmeier
no at spam.net
Wed Jul 31 14:19:20 UTC 2019
On Wednesday, 31 July 2019 at 07:19:12 UTC, BoQsc wrote:
> There are some other bad news, I switched from rdmd to dub
> package manager since I need a package from Adam D. Ruppe.
>
> It is all good and well: this one works perfectly.
>>#!/usr/bin/env dub
>>/+ dub.sdl:
>> name "hello"
>>
>>+/
>>import std.stdio;
>>void main()
>>{
>> writeln(`Content-type: text/html`);
>> writeln(``);
>> writeln(`<body style="background: lightgreen">CGI D
>> Example</body>`);
>>
>>
> }
>
>
> But, once I add dub dependency, the error appears: Internal
> Server Error
>>#!/usr/bin/env dub
>>/+ dub.sdl:
>> name "hello"
>> dependency "arsd-official" version="~>4.0.1"
>>
>>+/
>>import std.stdio;
>>void main()
>>{
>> writeln(`Content-type: text/html`);
>> writeln(``);
>> writeln(`<body style="background: lightgreen">CGI D
>> Example</body>`);
>>
>>
> }
>
> This seems to work well when running not from cgi, so there is
> no syntax error.
I'm curious why you don't just compile the binary and put it in
the CGI directory. That's what I've always done. This AFAICT (I
don't often use Dub) is going to compile every time it runs,
which makes the program unnecessarily slow, and if it's used
heavily, will add quite a load to the server. If you use Adam's
cgi.d, you can test your program at the command line, and even
run a server on localhost to test it in your browser.
More information about the Digitalmars-d-learn
mailing list