-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
26 lines (20 loc) · 959 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, render_template, request, redirect, url_for, send_file
import datetime
from utils import get_helioview_image, download_file, get_image_id, get_image_metadata, make_filename, remove_file, make_zip_file
import json
import os
app = Flask(__name__)
@app.route("/")
def index():
if os.path.exists('sun_data.zip'):
os.remove('sun_data.zip')
return render_template("index.html")
@app.route("/sun")
def sun():
start_datetime = datetime.datetime.strptime(f"{request.args.get('start_date')} {request.args.get('start_time')}", "%Y-%m-%d %H:%M:%S")
end_datetime = datetime.datetime.strptime(f"{request.args.get('end_date')} {request.args.get('end_time')}", "%Y-%m-%d %H:%M:%S")
source_id = request.args.get("source_id")
make_zip_file(start_datetime, end_datetime, source_id)
return send_file('sun_data.zip', attachment_filename='sun_data.zip', as_attachment=True)
if __name__ == "__main__":
app.run()