<commit_before>from flask import Flask, request, abort
from router import send_to_kannel
app = Flask(__name__)

@app.route("/")
def index():
        return "<h2>Welcome to chowk!</h2>"

@app.route("/sendsms/", methods = ['POST'])
def sendsms():
    if not request.method == 'POST':
        return "Wrong request. Get off my server you idiot and RTFM!"
    else:
        try:
            #TODO: Validate data and sanitize it a bit (?? sanitizing necessary ??)

            #Collect data in the msg
            msg = {}
            msg['to'] = request.form['to']
            msg['channel'] = request.form['channel']
            msg['from'] = request.form['from']
            msg['text'] = request.form['text']
            msg['id'] = request.form['id']

            #construct and send it forward
            status = send_to_kannel(msg = msg, app = app)
            if status is False:
                return "Bad luck! Couldn't deliver your message. Try again later in 30 minutes."
                abort(500)
            else:
                return "OK"
        except KeyError as e:
            print e
            print e.msg
            raise e
            return "Wrong request data. Get off my server you idiot and RTFM!"

if __name__ == "__main__":
       app.run(debug = True, host = '0.0.0.0')
       from logging import FileHandler,DEBUG
       file_handler = FileHandler('./loggedfile.log')
       file_handler.setLevel(DEBUG)
       app.logger.addHandler(file_handler)<commit_msg>Adding a stub receivesms method for handling incoming messages from Kannel server<commit_after>from flask import Flask, request, abort
from router import send_to_kannel
app = Flask(__name__)

@app.route("/")
def index():
        return "<h2>Welcome to chowk!</h2>"

@app.route("/sendsms/", methods = ['POST'])
def sendsms():
    if not request.method == 'POST':
        return "Wrong request. Get off my server you idiot and RTFM!"
    else:
        try:
            #TODO: Validate data and sanitize it a bit (?? sanitizing necessary ??)

            #Collect data in the msg
            msg = {}
            msg['to'] = request.form['to']
            msg['channel'] = request.form['channel']
            msg['from'] = request.form['from']
            msg['text'] = request.form['text']
            msg['id'] = request.form['id']

            #construct and send it forward
            status = send_to_kannel(msg = msg, app = app)
            if status is False:
                return "Bad luck! Couldn't deliver your message. Try again later in 30 minutes."
                abort(500)
            else:
                return "OK"
        except KeyError as e:
            print e
            print e.msg
            raise e
            return "Wrong request data. Get off my server you idiot and RTFM!"

@app.route("/receivesms/", methods = ['POST','GET'])
def recievesms():
    app.logging.debug("Recieved data %s", request.form)
    return "Ok"

if __name__ == "__main__":
       app.run(debug = True, host = '0.0.0.0')
       from logging import FileHandler,DEBUG
       file_handler = FileHandler('./loggedfile.log')
       file_handler.setLevel(DEBUG)
       app.logger.addHandler(file_handler)
{'fraction_non_alphanumeric': 0.11858573216520651, 'fraction_numerical': 0.00688360450563204, 'mean_word_length': 2.0769971126082774, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '383696', 'n_tokens_mistral': 925, 'n_tokens_neox': 897, 'n_words': 291}