<commit_before>import bottle 
import dotenv
import os
import pytz
import random
import shutil
import subprocess
import tempfile 
import uwsgi
import requests
from datetime import datetime, timedelta
from six.moves import urllib
import re

dotenv.load_dotenv(dotenv.find_dotenv())

bottle.TEMPLATE_PATH.append('./gokart/views')
bottle.debug(True)

# serve up map apps
@bottle.route('/<app_name>')
def index( app_name ):
    return bottle.jinja2_template('apps/{}.html'.format( app_name ), env=os.environ)


# WMS shim for Himawari 8
# Landgate tile servers, round robin
FIREWATCH_SERVICE = os.environ.get("FIREWATCH_SERVICE", "/mapproxy/firewatch/service")
FIREWATCH_GETCAPS = os.environ.get("FIREWATCH_GETCAPS", "http://srss-ows-6.landgate.wa.gov.au" + FIREWATCH_SERVICE + "?service=wms&request=getcapabilities")
@bottle.route("/hi8/<target>")
def himawari8(target):
    if uwsgi.cache_exists("himawari8"):
        getcaps = uwsgi.cache_get("himawari8").decode("utf-8")
    else:
        getcaps = requests.get(FIREWATCH_GETCAPS).content
        uwsgi.cache_set("himawari8", getcaps, 60*10) # cache for 10 mins
    layernames = re.findall("\w+HI8\w+{}\.\w+".format(target), getcaps)
    layers = []
    for layer in layernames:
        layers.append([datetime.strptime(re.findall("\w+_(\d+)_\w+", layer)[0], "%Y%m%d%H%M").isoformat(), layer])
    result = {
        "servers": [FIREWATCH_SERVICE],
        "layers": layers
    }
    return result<commit_msg>move base URL into FIREWATCH_SERVICE, fix UTF-8 decode<commit_after>import bottle 
import dotenv
import os
import pytz
import random
import shutil
import subprocess
import tempfile 
import uwsgi
import requests
from datetime import datetime, timedelta
from six.moves import urllib
import re

dotenv.load_dotenv(dotenv.find_dotenv())

bottle.TEMPLATE_PATH.append('./gokart/views')
bottle.debug(True)

# serve up map apps
@bottle.route('/<app_name>')
def index( app_name ):
    return bottle.jinja2_template('apps/{}.html'.format( app_name ), env=os.environ)


# WMS shim for Himawari 8
# Landgate tile servers, round robin
FIREWATCH_SERVICE = os.environ.get("FIREWATCH_SERVICE", "/mapproxy/firewatch/service")
FIREWATCH_GETCAPS = os.environ.get("FIREWATCH_GETCAPS", FIREWATCH_SERVICE + "?service=wms&request=getcapabilities")
@bottle.route("/hi8/<target>")
def himawari8(target):
    if uwsgi.cache_exists("himawari8"):
        getcaps = uwsgi.cache_get("himawari8")
    else:
        getcaps = requests.get(FIREWATCH_GETCAPS).content.decode("utf-8")
        uwsgi.cache_set("himawari8", getcaps, 60*10) # cache for 10 mins
    layernames = re.findall("\w+HI8\w+{}\.\w+".format(target), getcaps)
    layers = []
    for layer in layernames:
        layers.append([datetime.strptime(re.findall("\w+_(\d+)_\w+", layer)[0], "%Y%m%d%H%M").isoformat(), layer])
    result = {
        "servers": [FIREWATCH_SERVICE],
        "layers": layers
    }
    return result
{'fraction_non_alphanumeric': 0.1419753086419753, 'fraction_numerical': 0.011659807956104253, 'mean_word_length': 4.556190476190476, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6494496', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1069, 'n_words': 205}