Esempio n. 1
0
'''
Sample USSD apps running on the Africa's Talking Gateway using Bottle
(http://docs.africastalking.com/ussd)
'''
from libs.bottle import Bottle, response, request
import AfricasTalkingUssd as at
import at_client
import re,random,json,argparse

app = Bottle()
app.mount('/client',at_client.client)
app.mount('/static',at_client.static)
CACHE = {}

# create the index route that only accepts post requests
@app.post('/')
def index():

    # Enable CORS (Cross Domain POST)
    response.headers['Access-Control-Allow-Origin'] = '*'

    ussd = at.AfricasTalkingUssd(request.POST)

    if ussd.text == "":
        # This is the first hit of the service so return the main menu
        menu,next_menu = at.make_menu('Simple USSD Test',[
            'Guess A Number',
            'Convert KSH',
            'Random Swahili Words',
            'Random Hindi Words',
            'My Phone Number'
Esempio n. 2
0
from libs.bottle import Bottle, static_file, response
from AfricasTalkingUssd import enable_cors

client = Bottle()

@client.route('/')
@enable_cors
def test():
    return static_file('test.html',root='static')

static = Bottle()
@static.route('/<filename>')
def static_server(filename):
    return static_file(filename,root='static')

client.mount('/static',static)

if __name__ == '__main__':
    client.run(host='localhost',port='4040',debug=True,reloader=True)