I am new to this forum and must admit that Python is not my best friend.
However I am forced to deal with it since I need to make a plugin server to be used in X-Plane.
The thing is that X-Plane has support for Python scripts and can run using this code as a bare minimun.
- Code: Select all
from XPLMDefs import *
from XPLMUtilities import *
from XPLMProcessing import *
from XPLMDataAccess import *
self.Name = "PTserver"
self.Sig = "SandyBarbour.Python.Template"
self.Desc = "A test script for the Python Interface."
self.ser = SocketPlugin()
return self.Name, self.Sig, self.Desc
def XPluginReceiveMessage(self, inFromWho, inMessage, inParam):
Where I am struggling is to add a simple http server for sending and receiving a text string when an incomming request is made.
There are lots of general Python example code to be found online and I am able to start and use a server if I go via a Mac Terminal session.
Here is an example http://fragments.turtlemeat.com/pythonwebserver.php
The big problem is that the server must be threaded and non-blocking so it does not mess up the call backs in the plugin.
The classes in Python confuses me big time because it works in a diferent way that I am use tu in ex. Lua scripting.
Can someone please help me in the right direction.
Laid out simple:
Start a http server that serves and takes request in a parallel thread to the X-Plane script, and able to interact via a text string ......