Beispiel #1
0
def root():
    data = apod.get_apod(date.today())
    while data is None:
        data = apod.get_apod(date.today() - timedelta(1))
    return render_template('main.html',
                           title=data['title'],
                           img_url=data['image_url'],
                           credits=data['credits'],
                           summary=data['summary'])
Beispiel #2
0
def root_pdf():
    data = apod.get_apod(date.today())
    while data is None:
        data = apod.get_apod(date.today() - timedelta(1))
    file = p.pdf(data)
    file_data = BytesIO()
    with open(file, 'rb') as f:
        file_data.write(f.read())
    file_data.seek(0)
    os.remove(file)
    return send_file(file_data, mimetype='application/pdf')
Beispiel #3
0
def api(year, month, day):
    try:
        d = date(int(year), int(month), int(day))
    except ValueError:
        return jsonify({'status': 'INVALID DATE'})
    data = apod.get_apod(d)
    if data is None:
        return jsonify({'status': 'APOD NOT FOUND'})
    data.update({'status': 'ok'})
    return jsonify(data)
Beispiel #4
0
def api_pdf(year, month, day):
    try:
        d = date(int(year), int(month), int(day))
    except ValueError:
        return jsonify({'status': 'INVALID DATE'})
    data = apod.get_apod(d)
    if data is None:
        return jsonify({'status': 'APOD NOT FOUND'})
    file = p.pdf(data)
    file_data = BytesIO()
    with open(file, 'rb') as f:
        file_data.write(f.read())
    file_data.seek(0)
    os.remove(file)
    return send_file(file_data, mimetype='application/pdf')
Beispiel #5
0
def pdf(year, month, day):
    try:
        d = date(int(year), int(month), int(day))
    except ValueError:
        return render_template('invalid.html',
                               date=f'{year}-{month}-{day}'), 404
    data = apod.get_apod(d)
    if data is None:
        if d > date.today():
            return render_template('future.html', date=str(d)), 404
        elif d < date(1995, 6, 20):
            return render_template('past.html'), 404
        else:
            return render_template('dunno.html'), 404
    return redirect(f'/api/pdf/{year}/{month}/{day}')
Beispiel #6
0
def image(year, month, day):
    try:
        d = date(int(year), int(month), int(day))
    except ValueError:
        return render_template('invalid.html',
                               date=f'{year}-{month}-{day}'), 404
    data = apod.get_apod(d)
    if data is None:
        if d > date.today():
            return render_template('future.html', date=str(d)), 404
        elif d < date(1995, 6, 20):
            return render_template('past.html'), 404
        else:
            return render_template('dunno.html'), 404
    return render_template('image.html',
                           title=data['title'],
                           img_url=data['image_url'],
                           credits=data['credits'],
                           summary=data['summary'],
                           date=data['date'])
Beispiel #7
0
def launches():
	return render_template('launches.html', launches = get_launches(), apod_pic = get_apod())
Beispiel #8
0
def news():
	return render_template('news.html', apod_pic = get_apod())
Beispiel #9
0
def home():
  	return render_template('index.html', string = in_space(), apod_pic = get_apod())