-
Notifications
You must be signed in to change notification settings - Fork 0
Home
HTTPServer is a 4D component, built with 4D v18, which includes methods to help your web developing.
This is a 4D component, so you should build this source as 4D component and place it in the "Components" folder of your project root.
Copy httpServer.conf
file and place it on your project root. You can find the file in this sample's project root.
Write following code in On Web Connection database method. OnWebConnection
is a shared component method.
C_TEXT($1;$2;$3;$4;$5;$6)
OnWebConnection($3;$4)
Then write following code in On (Server) Startup database method. new HttpServer
is also a shared component method which is used to build your web application.
C_OBJECT($app_o)
$app_o:=new HttpServer()
$app_o.get("/hello"; Formula(HelloWorld))
$app_o.start()
HelloWorld
method looks like
C_OBJECT($1;$req_o)
C_OBJECT($2;$res_o)
C_OBJECT($3;$next_o)
$req_o:=$1
$res_o:=$2
$next_o:=$3
$res_o.send("Hello World")
Then restart your project, make sure the HTTP server is up and running, connect to http://localhost/hello
with your favorite web browser. You will get "Hello World" response.
Please refer to the demo is in the "test" folder. Just launch it with 4D v18 Standalone and connect to it with your favorite web browser via http://localhost/.