46 lines
1.4 KiB
Python

from flask import Blueprint, render_template, current_app, request
from .models import ScheduleConfig, VolumeConfig
from .db import db
bp = Blueprint('main', __name__)
@bp.route("/")
def index():
return render_template("index.html")
@bp.route("/upload", methods=["GET", "POST"])
def upload():
if request.method == "POST":
# CSV upload logic here
pass
return render_template("upload.html")
@bp.route("/papers")
def papers():
return render_template("papers.html", app_title="PaperScraper")
@bp.route("/schedule", methods=["GET", "POST"])
def schedule():
if request.method == "POST":
for hour in range(24):
key = f"hour_{hour}"
weight = float(request.form.get(key, 0))
config = ScheduleConfig.query.get(hour)
if config:
config.weight = weight
else:
db.session.add(ScheduleConfig(hour=hour, weight=weight))
db.session.commit()
schedule = {sc.hour: sc.weight for sc in ScheduleConfig.query.order_by(ScheduleConfig.hour).all()}
volume = VolumeConfig.query.first()
return render_template("schedule.html", schedule=schedule, volume=volume.volume, app_title="PaperScraper")
@bp.route("/logs")
def logs():
return render_template("logs.html", app_title="PaperScraper")
@bp.route("/about")
def about():
return render_template("about.html", app_title="PaperScraper")