2023-10-30 15:56:29 +08:00
|
|
|
from flask import Flask, render_template, redirect, url_for
|
|
|
|
from loguru import logger
|
|
|
|
|
2023-11-03 16:58:54 +08:00
|
|
|
import const
|
|
|
|
import models
|
|
|
|
import tools
|
|
|
|
from generator import Generator
|
2023-10-30 15:56:29 +08:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
logger.add("endofyear.log")
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def home():
|
2023-11-03 16:58:54 +08:00
|
|
|
# 重定向 painting
|
2023-10-30 15:56:29 +08:00
|
|
|
return redirect(url_for('painting'))
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/painting')
|
|
|
|
def painting():
|
2023-11-03 16:58:54 +08:00
|
|
|
# 站点数据
|
|
|
|
site = models.Site(
|
|
|
|
service=const.SITE_SERVICE,
|
|
|
|
title=const.SITE_NAME
|
|
|
|
).to_dict()
|
|
|
|
|
|
|
|
# 自定义数据
|
|
|
|
custom = models.Custom(
|
|
|
|
yiyan=tools.get_yiyan()
|
|
|
|
).to_dict()
|
|
|
|
|
|
|
|
# 初始化数据生成器
|
|
|
|
generator = Generator("https://blog.7wate.com/rss.xml")
|
|
|
|
|
|
|
|
# 渲染模板
|
|
|
|
return render_template('painting.html',
|
|
|
|
site=site,
|
|
|
|
blog=generator.blog(),
|
|
|
|
special_post=generator.special_post(),
|
|
|
|
sentiment_post=generator.sentiment_post(),
|
|
|
|
long_post=generator.long_post(),
|
|
|
|
short_post=generator.short_post(),
|
|
|
|
custom=custom
|
|
|
|
)
|
2023-10-30 15:56:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(host='0.0.0.0', port=7777, debug=True)
|