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
main.py is enumerated and outputted by
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): print("hello") print("there") if __name__ == "__main__": main()
local lines = py("main.py") print(dir(lines))
The served page will look like this:
1 -> hello 2 -> there
python is not in the path, it's possible to use the
run() function instead of
/somehwere/ must point to the right location:
local lines = run("/somewhere/python main.py") print(dir(lines))