import os
import json

from flask import Flask, render_template


def channels_json(station, escaped=False):
    channels = [{"name": channel} for channel in station.channels()]
    jsonbody = json.dumps(channels)
    if escaped:
        jsonbody = jsonbody.replace("</", "<\\/")
    return jsonbody


def make_airship(station):
    app = Flask(__name__)

    @app.route("/")
    def index():
        return render_template("index.html", channels_json=channels_json(station, True))

    @app.route("/channels")
    def list_channels():
        return channels_json(station)

    @app.route("/grefs/<channel>")
    def list_grefs(channel):
        return


    return app

@@ -67,237 +67,449 @@
 def 
-channels_json(station, escaped=False):%0A    channels = %5B%7B%22name%22: channel%7D for channel in station.channels()%5D%0A    jsonbody = json.dumps(channels)%0A    if escaped:%0A        jsonbody = jsonbody.replace(%22%3C/%22, %22%3C%5C%5C/%22)%0A    return jsonbody
+jsonate(obj, escaped):%0A    jsonbody = json.dumps(obj)%0A    if escaped:%0A        jsonbody = jsonbody.replace(%22%3C/%22, %22%3C%5C%5C/%22)%0A    return jsonbody%0A%0A%0Adef channels_json(station, escaped=False):%0A    channels = %5B%7B%22name%22: channel%7D for channel in station.channels()%5D%0A    return jsonate(channels, escaped)%0A%0A%0Adef grefs_json(station, channel, escaped=False):%0A    grefs = %5B%7B%22name%22: gref%7D for gref in station.grefs(channel)%5D%0A    return jsonate(grefs, escaped)
 %0A%0A%0Ad
@@ -858,17 +858,45 @@
   return
-%0A
+ grefs_json(station, channel)
 %0A%0A    re

Fix the grefs route in the airship server