The godottpd documentation gives this example on how to start a server:
var server = HttpServer.new()
server.register_router("/", MyExampleRouter.new())
server.start()
However, that code by itself won't work because HttpServer is a Node and uses the _process method to listen to requests. If it's not added to the scene, _process won't run and it won't listen to requests.
Documentation should be improved to mention that fact and either suggest that the user add HttpServer on the scene tree or suggest the following code
var server = HttpServer.new()
server.register_router("/", MyExampleRouter.new())
self.add_child(server) # Assuming "self" is a script extending Node that's inserted on a scene or it's root
server.start()
The godottpd documentation gives this example on how to start a server:
However, that code by itself won't work because HttpServer is a Node and uses the _process method to listen to requests. If it's not added to the scene, _process won't run and it won't listen to requests.
Documentation should be improved to mention that fact and either suggest that the user add HttpServer on the scene tree or suggest the following code