From 71b7c639fa0b4ffe7425ec9bd6c3b0fef08b0028 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Sat, 1 Jul 2023 20:07:33 +0200 Subject: Post: Added Python example to Caddy post --- ...my-projects-together-under-a-single-umbrella.md | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/content/posts/2023-07-01-bringing-all-of-my-projects-together-under-a-single-umbrella.md b/content/posts/2023-07-01-bringing-all-of-my-projects-together-under-a-single-umbrella.md index a08614f..259d4fc 100644 --- a/content/posts/2023-07-01-bringing-all-of-my-projects-together-under-a-single-umbrella.md +++ b/content/posts/2023-07-01-bringing-all-of-my-projects-together-under-a-single-umbrella.md @@ -105,6 +105,7 @@ examples.mitjafelicijan.com { cgi /bash-test /opt/projects/examples/bash-test.sh cgi /tcl-test /opt/projects/examples/tcl-test.tcl cgi /lua-test /opt/projects/examples/lua-test.lua + cgi /python-test /opt/projects/examples/python-test.py root * /opt/projects/examples file_server @@ -119,8 +120,8 @@ examples.mitjafelicijan.com { config file. I did a small batch of tests with [Bash](https://www.gnu.org/software/bash/), -[Tcl](https://www.tcl-lang.org/) and [Lua](https://www.lua.org/). Here is a -cheat sheet if you need it. +[Tcl](https://www.tcl-lang.org/), [Lua](https://www.lua.org/) and +[Python](https://www.python.org/). Here is a cheat sheet if you need it. Let's get Bash out the way first. @@ -158,6 +159,24 @@ for {set i 0} {$i < 10} {incr i} { } ``` +And for all you Python enjoyers. + +```python +#!/usr/bin/python3 + +import os + +print("Content-type: text/plain\n") + +print("Hello from Python\n") +print("PATH_INFO [{}]".format(os.environ['PATH_INFO'])) +print("QUERY_STRING [{}]".format(os.environ['QUERY_STRING'])) +print("") + +for i in range(10): + print("> {}".format(i)) +``` + And for the final example, Lua. ```lua @@ -194,6 +213,7 @@ examples.mitjafelicijan.com { cgi /bash-test /opt/projects/examples/bash-test.sh cgi /tcl-test /opt/projects/examples/tcl-test.tcl cgi /lua-test /opt/projects/examples/lua-test.lua + cgi /python-test /opt/projects/examples/python-test.py root * /opt/projects/examples file_server -- cgit v1.2.3