Ejemplo n.º 1
0
def related_articles(article_id):
    if len(article_id) != 16:
        return "404 Not found", 404
    article = nihongodeok.async_get_article(article_id)
    related_articles = nihongodeok.async_get_related_articles(article_id, 20)
    if article.response.status == 404 or related_articles.response.status == 404:
        return "404 Not found", 404
    article = article.decode_json()
    related_articles = related_articles.decode_json()
    return flask.render_template("related_articles.html", article=article, related_articles=related_articles)
Ejemplo n.º 2
0
def article(article_id):
    article = nihongodeok.async_get_article(article_id)
    related_articles = nihongodeok.async_get_related_articles(article_id)

    if article.response.status == 404:
        return "404 Not found", 404

    article = article.decode_json()
    related_articles = related_articles.decode_json()

    url = article["url"]

    pagecapture_path = "/%s/%s.png" % (article_id[:2], article_id)
    img_exists = nihongodeok.async_head(nihongodeok.pagecapture_base + pagecapture_path)
    pagecapture = None
    if img_exists.response.status == 200:
        pagecapture = nihongodeok.pagecapture_external_base + pagecapture_path
    else:
        nihongodeok.request_page_capture(url)

    return flask.render_template(
        "article.html", article=article, pagecapture=pagecapture, related_articles=related_articles
    )