-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
49 lines (34 loc) · 1.13 KB
/
app.py
File metadata and controls
49 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from flask import Flask, render_template,request
# Newspaper Module -Used for Article Extraction
import nltk
from newspaper import Article
app=Flask(__name__)
@app.route('/',methods=['GET','POST'])
def index():
return render_template("index.html")
@app.route('/home',methods=['GET','POST'])
def home():
if request.method=="POST" :
url=request.form['url']
print(url)
article = Article(url)
# # # Do some NLP
article.download()
article.parse()
# nltk.download('punkt')
# article.nlp()
# #Get the authors
# article.authors
# #Get the publish date
# article.publish_date
# #Get the top image
# article.top_image
# #Get the article text
# print(article.text)
fetched_article=(article.text)
fetched_article=fetched_article.split('\n')
article_title=article.title
# return render_template("index.html")
return render_template("index.html",fetched_article=fetched_article,article_title=article_title)
if __name__=='__main__':
app.run(debug=True)