Example #1
0
def ft_api_status():
    # First, read the database and obtain all the info
    conn = ft_db_connect_sqlite()
    c = conn.cursor()
    c.execute('SELECT id, userid, starttime, stoptime, status FROM `work`;')
    result = c.fetchall()
    conn.close()

    # Second, make a response
    resp = make_response()
    resp.headers['Content-Type'] = 'text/xml'
    resp.data = render_template('status.xml', result=result)
    return resp
Example #2
0
def ft_api_obtain(work_id):
    # First, open database conn and find the record
    conn = ft_db_connect_sqlite()
    c = conn.cursor()
    try:
        work_id = int(work_id)
    except ValueError:
        abort(400)
    found = False
    for i in c.execute('SELECT status, output FROM `work` WHERE id=?;', (work_id,)):
        found = True
        break
    if not found or not i[0] == "S": # NOT SUCCESSFUL
        abort(404)
    resp =make_response(i[1], 200)
    resp.headers['Content-Type'] = 'application/pdf'
    conn.close()
    return resp