Combining with Python

The best way is probably to make Python place the data directly in the database, then display it with a combination of Pongo2 and Lua.

Another method is to write a Python script that outputs data to a JSON file that can then be read by Lua.

Yet another method is to write a Python plugin and use the plugin system.

The following is for Algernon >0.87.

It is possible to run a Python script at every request, using the py() function. This is easy to get started with, but scales badly.

Here is an example where the output from is enumerated and outputted by index.lua:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():

if __name__ == "__main__":


local lines = py("")

The served page will look like this:

1                   ->    hello
2                   ->    there

If python is not in the path, it's possible to use the run() function instead of py(), where /somehwere/ must point to the right location:


local lines = run("/somewhere/python")