Freeswitch embedded python script, freeswitchpython
Operating System: debian8.5 _ x64
Freeswitch version: 1.6.8
Python version: 2.7.9
Enable the python Module
Install the python lib Library
apt-get install python-dev
Edit modules. conf and enable the python module:
languages/mod_python
Compile and install:
./configure && make && make install
Enable python support in modules. conf. xml;
Start freeswitch;
Test script API Test
Add test script:
File Path:/usr/local/freeswitch/scripts/test1.py
File Content:
import freeswitchdef fsapi(session,stream,env,args): stream.write("hello") freeswitch.consoleLog("info","test")
Console Test
freeswitch@debian8> python test1hello2016-09-06 23:06:09.069753 [NOTICE] mod_python.c:212 Invoking py module: test12016-09-06 23:06:09.069753 [DEBUG] mod_python.c:283 Call python script2016-09-06 23:06:09.069753 [INFO] switch_cpp.cpp:1360 test2016-09-06 23:06:09.069753 [DEBUG] mod_python.c:286 Finished calling python scriptfreeswitch@debian8>
APP Testing
File Path:/usr/local/freeswitch/scripts/testCall. py
File Content:
import freeswitchdef handler(session, args): session.answer() freeswitch.console_log("info","testCall") session.streamFile("local_stream://moh") freeswitch.msleep(3000) session.hangup()
Add the following configuration to dialplan:
<extension name="python test script"> <condition field="destination_number" expression="^400123456$"> <action application="python" data="testCall"/> </condition></extension>
Register the phone number, call 400123456 to hear the moh sound, and view the freeswitch console log.
Github address:
Bytes
Please add