Hello world/Web server: Difference between revisions
Content added Content deleted
(perl: now the plack/plackup examples with port 8080) |
|||
Line 795: | Line 795: | ||
simple_http_server(8080, procedure(header, connection) |
simple_http_server(8080, procedure(header, connection) |
||
{ respond_text(connection, "Goodbye, World!"); });</lang> |
{ respond_text(connection, "Goodbye, World!"); });</lang> |
||
=={{header|Smalltalk}}== |
|||
{{works with|Smalltalk/X}} |
|||
starting server: |
|||
<lang smalltalk>Smalltalk loadPackage:'stx:goodies/webServer'. "usually already loaded" |
|||
|myServer service| |
|||
myServer := HTTPServer startServerOnPort:8082. |
|||
service := HTTPPluggableActionService new. |
|||
service register:[:request | self halt. request reply:'<HTML><BODY><H1>Hello World</H1></BODY></HTML>'] as:'hello'. |
|||
service linkNames:#('/' ). |
|||
service registerServiceOn: myServer. |
|||
myServer start.</lang> |
|||
Be aware that the above is an ad-hoc minimal scripting example. Normally, a service subclass is used and response handlers are defined as methods of it (not as action blocks). |
|||
Also, services and HTML generation is usually done using a framework (at least DOM-based, but usually a higher level toolkit). |
|||
Especially take a look at smalltalk frameworks like Aida, Seaside, VisualWave etc. |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |