from
flask
import
Flask,Response
from
flask
import
request
from
bs4
import
BeautifulSoup
import
json
app = Flask(__name__)
if
'
_name_'
==
'
_main_'
:
app.run(threaded=True)
@app
.route(
'
/'
)
def
home():
return
'
News API is UP!<br><br> itis hsh hfslab s,djhdsbf s,ajsbf ajsdfbs '
@app
.route(
'
/news'
, methods=[
'
GET'
])
def
handlle_request():
url =
'
https://www.indiatoday.in/rss/home'
r = request.args.get(url)
soup = BeautifulSoup(r.content,
'
xml'
)
items = soup.findAll(
'
item'
)
newList = []
for
item
in
items:
title = item.find(
"
title"
).text.strip()
url = item.find(
"
link"
).text.strip()
new = {
"
title"
:title,
"
url"
:url
newList.append(new)
y= json.dumps(newList, indent=2)
return
Response(y , mimetype=
"
application/json"
)
What I have tried:
what error I got
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/home/jonsnow99/mysite/flask_app.py", line 15, in handlle_request
r = request.get(url)
AttributeError: 'Request' object has no attribute 'get'
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question
and fix the problem. Insults are not welcome.
Don't tell someone to read the manual. Chances are they have and don't get it.
Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.