mirror of
https://github.com/MathiasDPX/blog.git
synced 2025-05-10 07:33:09 +00:00
fix: pylint
This commit is contained in:
parent
761e6d810a
commit
836b91aa67
1 changed files with 10 additions and 8 deletions
18
main.py
18
main.py
|
@ -1,15 +1,18 @@
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import os
|
||||||
from flask import Flask, render_template, request, send_file, make_response
|
from flask import Flask, render_template, request, send_file, make_response
|
||||||
from routes.editor import editor_routes
|
|
||||||
from feedgen.feed import FeedGenerator
|
from feedgen.feed import FeedGenerator
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
from routes.editor import editor_routes
|
||||||
from classes import *
|
from classes import *
|
||||||
import json, re, os
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.register_blueprint(editor_routes)
|
app.register_blueprint(editor_routes)
|
||||||
|
|
||||||
articles_data = json.load(open("articles.json", "r", encoding="utf-8"))
|
with open("articles.json", "r", encoding="utf-8") as f:
|
||||||
|
articles_data = json.load(f)
|
||||||
categories = {} # Category name:str -> [Article]
|
categories = {} # Category name:str -> [Article]
|
||||||
articles = {} # ID:str = Article
|
articles = {} # ID:str = Article
|
||||||
|
|
||||||
|
@ -23,16 +26,15 @@ fg.description("Blog RSS feed")
|
||||||
|
|
||||||
for article_data in articles_data:
|
for article_data in articles_data:
|
||||||
category_name = article_data.get("category", "Uncategorized")
|
category_name = article_data.get("category", "Uncategorized")
|
||||||
|
|
||||||
category_list = categories.get(category_name, [])
|
category_list = categories.get(category_name, [])
|
||||||
|
|
||||||
article = Article(
|
article = Article(
|
||||||
template=article_data.get("template"),
|
template=article_data.get("template"),
|
||||||
title=article_data.get("title"),
|
title=article_data.get("title"),
|
||||||
category=category_name
|
category=category_name
|
||||||
)
|
)
|
||||||
|
|
||||||
if article.template in list(articles.keys()):
|
if article.template in articles.keys():
|
||||||
raise KeyError(f"Two articles linking to the same template ({article.template})")
|
raise KeyError(f"Two articles linking to the same template ({article.template})")
|
||||||
|
|
||||||
articles[article.template] = article
|
articles[article.template] = article
|
||||||
|
@ -79,4 +81,4 @@ def article(article_id:str):
|
||||||
return render_template(f"articles/{article.template}.html")
|
return render_template(f"articles/{article.template}.html")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run()
|
app.run()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue