FreeSWITCH Embedding Python scripts

Source: Internet
Author: User

Operating system: debian8.5_x64

FreeSWITCH version: 1.6.8

Python version: 2.7.9

Open Python Module

Installing the Python Lib Library

Install Python-dev

To edit the modules.conf, open the Python module:

Languages/mod_python

Compile and install:

 Make  Make Install

Open Python support in modules.conf.xml;

Start FreeSWITCH;

Test Script API Test

To add a test script:

File path:/usr/local/freeswitch/scripts/test1.py

File contents:

Import FreeSWITCH def Fsapi (Session,stream,env,args):   stream.write ("hello")   Freeswitch.consolelog ("info","test")

Console testing

[Email protected]>python Test1hello .- the- .  at: .:09.069753[NOTICE] Mod_python.c:212invoking PY Module:test1 .- the- .  at: .:09.069753[DEBUG] Mod_python.c:283Call python script .- the- .  at: .:09.069753[INFO] Switch_cpp.CPP:1360Test .- the- .  at: .:09.069753[DEBUG] Mod_python.c:286finished calling Python Script[email protected]>
App Test

File path:/usr/local/freeswitch/scripts/testcall.py

File contents:

Import FreeSWITCH def handler (session, args):    session.answer ()    freeswitch.console_log ("info" ,"testcall")    session.streamfile ("Local_ Stream://moh")    freeswitch.msleep (+)    Session.hangup ()

Add the following configuration to the DialPlan:

<extensionname= "python test script">        <conditionField= "Destination_number"expression= "^400123456$">            <ActionApplication= "Python"Data= "Testcall"/>        </condition></extension>

Register the phone, dial No. 400123456 number to hear MoH sound, and see the FreeSWITCH console log.

This article GitHub address:

Https://github.com/mike-zhang/mikeBlogEssays/blob/master/2016/20160906_freeswitch embedded Python script . MD

Welcome to Supplement

FreeSWITCH Embedding Python scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.