import logging
from typing import Union

from flask import Flask, request, jsonify
from catt.controllers import setup_cast, CastController

app = Flask(__name__)

#logging.basicConfig(level=logging.DEBUG)

cast_controller = None  # type: Union[None, CastController]


@app.route("/")
def root():
    return {
        "msg": "Hello, there!"
    }


@app.route("/cast_site", methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'],
                         controller="dashcast", 
                         action="load_url", 
                         prep="app")
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route("/stop_cast", methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')

45f1889f3e6368dc5f3b3b704e32d7ce0055b058
<mask token>


@app.route('/cast_site', methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'], controller='dashcast',
            action='load_url', prep='app')
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route('/stop_cast', methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')

<mask token>


@app.route('/')
def root():
    return {'msg': 'Hello, there!'}


@app.route('/cast_site', methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'], controller='dashcast',
            action='load_url', prep='app')
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route('/stop_cast', methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')

<mask token>
app = Flask(__name__)
cast_controller = None


@app.route('/')
def root():
    return {'msg': 'Hello, there!'}


@app.route('/cast_site', methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'], controller='dashcast',
            action='load_url', prep='app')
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route('/stop_cast', methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')

import logging
from typing import Union
from flask import Flask, request, jsonify
from catt.controllers import setup_cast, CastController
app = Flask(__name__)
cast_controller = None


@app.route('/')
def root():
    return {'msg': 'Hello, there!'}


@app.route('/cast_site', methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'], controller='dashcast',
            action='load_url', prep='app')
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route('/stop_cast', methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')

import logging
from typing import Union

from flask import Flask, request, jsonify
from catt.controllers import setup_cast, CastController

app = Flask(__name__)

#logging.basicConfig(level=logging.DEBUG)

cast_controller = None  # type: Union[None, CastController]


@app.route("/")
def root():
    return {
        "msg": "Hello, there!"
    }


@app.route("/cast_site", methods=['POST'])
def cast_site():
    global cast_controller
    data = request.json
    resp = jsonify(data)
    if data['device'] and data['url']:
        cast_controller = setup_cast(data['device'],
                         controller="dashcast", 
                         action="load_url", 
                         prep="app")
        cast_controller.load_url(data['url'])
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


@app.route("/stop_cast", methods=['POST'])
def stop_cast():
    data = request.json
    resp = jsonify(data)
    if cast_controller:
        cast_controller.kill()
        resp.status_code = 200
    else:
        resp.status_code = 500
    return resp


def run():
    app.run(port=9898, host='0.0.0.0')
