I just playing around with the websocket directive:-
localhost:4000
websocket /ws "python ws.py"
And the python script ws.py:-
import sys
import time
while True:
line=sys.stdin.readline().rstrip()
if line:
sys.stdout.write(line[::-1]+'\n')
sys.stdout.flush()
else:
sys.stdout.flush()
time.sleep(1)
Impressing ! But now if I need to listen to some webhook as part of this websocket app, I need to run python app server and proxy it from caddy. Why can’t we have similar directive to process normal web request like above too ?
Using proxy require me to manage another process. In websocket example above, it run python ws.py when there’s incoming connection, and then terminate it when the connection closed. But thinking further about this started to feel like this is exactly what CGI is.