Я пытался проверить мой feed.py, используя
python3 feed.py
завиток http://127.0.0.1:5000/rss/summary
Я получил ошибку при выполнении кода белым цветом.
введите описание изображения здесь
import os, datetime
import requests
from rfeed import Item, Feed
from flask import Flask, jsonify, request
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route("/rss/summary", methods=['GET'])
def summary():
response = requests.get("https://www.technologyreview.com/c/computing/rss/")
if response.status_code is 200:
data = response.json()
article_sum = []
for articles in data:
article_sum.append(
Item(
title = articles['title'],
author = articles['author'],
pubDate = datetime.datetime(2014, 12, 29, 10, 00),
link = articles['url']
)
)
feed = Feed(
title = "A summary feed listing",
link = "http://127.0.0.1:5000/rss/summary",
description = "a summary feed listing the title, author, date, and link for 10 most recent articles",
language = "en-US",
lastBuildDate = datetime.datetime.now(),
items = article_sum
)
return feed.rss()
else:
return response.status_code
if __name__ == '__main__':
app.run()