Nowadays, when creating a dynamic homepage, "launch a Linux instance with VPS", "deliver content using a Serverless framework", "use K8S etc. to drop it to Container" I think the recent trend is to "play".
However, until recently, it was common to rent a rental server and use CGI to deliver dynamic content. I will explain about this CGI.
Also, speaking of CGI, Perl and PHP are often used, Here, C language and Dart language are targeted.
There was no story I used for CGI in the Dart language, either DuckDuckGo or Google.
Of course, the reason there was none was classic technology, Probably because it was never used in the future
Is it around 2004-2006? PHP became widespread and many services were created with CGI. Many are non-engineers. Even such non-engineers A service that gives you an overall picture and makes money has been created.
Compared to Serverless such as React Vue Flutter and Firebase Lambda these days I think it was because it was easy to learn.
CGI stands for Common Gateway Interface. https://en.wikipedia.org/wiki/Common_Gateway_Interface https://tools.ietf.org/html/rfc3875
It determines how to interact, especially between the server and an external program. It's super simple unlike the current Interface.
In CGI, the application is started by specifying the parameters from the server. Get the standard output output by the app as the return value.
Let's take a concrete look.
hello.c
// hello.c
// gcc hello.c -o hello.cgi
#include<stdio.h>
int main(int argc, char* argv[]) {
printf("Content-type: text/html\n\n");
printf("Hello,World!!\n");
return 0;
}
Suppose you have an app named hello.cgi.
This app, when you enter the command ./hello.cgi
,
"""
Content-type: text/html
Hello,World!! """ And, it is an application that only displays the character string on the console.
If you call "http://example.com/hello.cgi" from your browser, "Hello, World !!" is displayed in the browser.
In this way, call the app from the server CGI can return the output from the application to the user
We have prepared a Docker environment. Please refer to the Docker file for detailed settings !!
$ git clone https://github.com/kyorohiro/dartlang_cgi.git
$ cd ./dartlang_cgi/001
$ docker-compose build
$ docker-compose up -d
Open VSCode in Docker Container in your browser http://127.0.0.1:8443
$ apache2
$ cd /app/www/cgi
$ gcc hello.c -o hello.cgi
$ dart2native hello_dart.dart -o hello_daet.cgi
When you open http://127.0.0.1:8080/, ./app/www/index.html will be displayed.
When you open http://127.0.0.1:8080/cgi-bin/hello.cgi. ./app/cgi/hello.cgi execution result is returned
Opening http://127.0.0.1:8080/cgi-bin/hello_dart.cgi will return the execution result of ./app/cgi/hello_dart.cgi
Dart can be compiled to Native by using dart2native. I'm using it this time.
main(List<String> args) {
print("Content-type: text/html\n\n");
print("Hello,World From Dart!!\n");
return 0;
}
https://github.com/kyorohiro/dartlang_cgi
GET, POST, cookies, Let's deal with DB.
Recommended Posts