We will explain in detail the steps to run a Python script on Lollipop’s server.
0. Preparation
Follow the steps below to
– SSH connection to Lollipop’s server
・Check Python version
– Install pip
Run the
1. Check the Python execution environment
Check your Python version
SSH to Lollipop’s server and check the installed version of Python.
python3 --versionExample output:
Python 3.7.17Preparing a directory for CGI – cgi-bincreating a directory
Lollipops require CGI scripts to be placed within a specific directory (e.g., ). cgi-bin
First,web create a directory insidecgi-bin the /<public folder> directory.
is the value specified in the public (upload) folder > your own domain settings.

mkdir -p ~/web/<公開フォルダ>/cgi-bin-pThe option is automatically created if the parent directory(web) does not exist.
Set the appropriate permissions in the directory of the CGI script.
chmod 755 ~/web/<公開フォルダ>/cgi-binconfirmation
Verify that the directory was created correctly
ls -ld ~/web/<公開フォルダ>/cgi-binExample output:
drwxr-xr-x 2 XXXX.XXXX LolipopUser 10 1月 1 12:00 /home/users/0/XXXX.XXXX/web/<公開フォルダ>/cgi-binPlace the file and check it in action Once you have created the directory in the above steps,cgi-bin upload a Python script to check it in action.
2. Prepare a Python script
Create a Python script.
Script example:
Save the following scriptexample.py as:
#!/usr/bin/env python3
print("Content-Type: text/html\n")
print("<html><body>")
print("<h1>Hello, Python on Lolipop!</h1>")
print("</body></html>")Point:
- Stated at
#!/usr/bin/env python3the beginning of the script (specify the Python path). - Be sure to output “
Content-Type(CGI script requirement).
3. Upload your script
Upload the script to the server’scgi-bin directory.
Way:
- Use FileZilla and more
- Connect using Lollipop’s FTP/SFTP information.
- in the directory of
cgi-binexample.pythe server.
- Permission Settings
- CGI scripts require execution permissions.
chmod 755 example.py4. Run in your browser
Access the uploaded script to see it in action.
Example URL:
https://あなたのドメイン/cgi-bin/example.pyNormal operation results:
- 「Hello, Python on Lolipop!」 If it is displayed, it is a success.

5. Periodic execution with Cron job (optional)
Lollipops allow you to utilize Cron to run Python scripts on a regular basis.
Way:
- Log in to the Lollipop management screen.
- Select “Server Management Settings” → “Cron Settings”.
- Create a new job.

Comments