''' 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'
Note : Certains IDE peuvent afficher des erreurs sur request.query.X c'est du au fait qu'ils ne gerent pas le format formsdict utilisé par bottle """ from libs.bottle import route, Bottle, request from toy_utils import LEN_SHA256, toy_digest from toy_utils import PIECE_FILE_EXTENSION, TORRENT_FILE_EXTENSION import bencoding """ =========================== SERVEUR DE TRACKING =========================== """ server = Bottle() server.tracker = None #Object of class Tracker from tracker """ route de test : verifie que le serveur est en ligne """ @server.route('/') def hello(): return "Welcome to " + server.tracker.id """ route principale : renvoie les peers enregistré par le tracker """
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)