<commit_before>#!/usr/bin/env python

import urllib
import json
import os

from flask import Flask
from flask import request
from flask import make_response

# Flask app should start in global layout
app = Flask(__name__)


@app.route('/webhook', methods=['POST'])
def webhook():
    req = request.get_json(silent=True, force=True)

    print("Request:")
    print(json.dumps(req, indent=4))

    res = processRequest(req)

    res = json.dumps(res, indent=4)
    print(res)
    r = make_response(res)
    r.headers['Content-Type'] = 'application/json'
    return r


# http://api.aladhan.com/timingsByCity?city=Dubai&country=AE&method=2

def processRequest(req):
    baseurl = "http://api.aladhan.com/timingsByCity?city=Dallas&country=USA&method=2"
    query = makeYqlQuery(req)
    if query is None:
        return {"404"}
    result = urllib.urlopen(query).read()
    data = json.loads(result)
    res = makeWebhookResult(data)
    return res

def makeYqlQuery(req):
    return "http://api.aladhan.com/timingsByCity?city=Dallas&country=USA&method=2"


def makeWebhookResult(data):
    adata = data.get('data')
    if adata is None:
        return {}

    timings = adata.get('timings')
    if timings is None:
        return {}

    #get fajr
    fajr = timings.get("Fajr")

    # item = channel.get('item')
    # location = channel.get('location')
    # units = channel.get('units')
    if (fajr is None):
        return {}

    # print(json.dumps(item, indent=4))

    speech = "Today Fajr is at ", fajr

    print("Response:")
    print(speech)

    return {
        "speech": speech,
        "displayText": speech,
        # "data": data,
        # "contextOut": [],
        "source": "prayer-times-api"
    }

if __name__ == '__main__':
    port = int(os.getenv('PORT', 5000))

    print "Starting app on port %d" % port

    app.run(debug=False, port=port, host='127.0.0.1')<commit_msg>fixing ip<commit_after>#!/usr/bin/env python

import urllib
import json
import os

from flask import Flask
from flask import request
from flask import make_response

# Flask app should start in global layout
app = Flask(__name__)


@app.route('/webhook', methods=['POST'])
def webhook():
    req = request.get_json(silent=True, force=True)

    print("Request:")
    print(json.dumps(req, indent=4))

    res = processRequest(req)

    res = json.dumps(res, indent=4)
    print(res)
    r = make_response(res)
    r.headers['Content-Type'] = 'application/json'
    return r


# http://api.aladhan.com/timingsByCity?city=Dubai&country=AE&method=2

def processRequest(req):
    baseurl = "http://api.aladhan.com/timingsByCity?city=Dallas&country=USA&method=2"
    query = makeYqlQuery(req)
    if query is None:
        return {"404"}
    result = urllib.urlopen(query).read()
    data = json.loads(result)
    res = makeWebhookResult(data)
    return res

def makeYqlQuery(req):
    return "http://api.aladhan.com/timingsByCity?city=Dallas&country=USA&method=2"


def makeWebhookResult(data):
    adata = data.get('data')
    if adata is None:
        return {}

    timings = adata.get('timings')
    if timings is None:
        return {}

    #get fajr
    fajr = timings.get("Fajr")

    # item = channel.get('item')
    # location = channel.get('location')
    # units = channel.get('units')
    if (fajr is None):
        return {}

    # print(json.dumps(item, indent=4))

    speech = "Today Fajr is at ", fajr

    print("Response:")
    print(speech)

    return {
        "speech": speech,
        "displayText": speech,
        # "data": data,
        # "contextOut": [],
        "source": "prayer-times-api"
    }

if __name__ == '__main__':
    port = int(os.getenv('PORT', 5000))

    print "Starting app on port %d" % port

    app.run(debug=False, port=port, host='0.0.0.0')
{'fraction_non_alphanumeric': 0.14482029598308668, 'fraction_numerical': 0.009513742071881607, 'mean_word_length': 3.096320346320346, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, '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': '6352665', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1302, 'n_words': 286}