from flask import Flask, request, render_template, redirect, url_for
from newspaper import Article
from xml.etree  import ElementTree

app = Flask(__name__)

# Debug logging
import logging
import sys
# Defaults to stdout
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
try: 
    log.info('Logging to console')
except:
    _, ex, _ = sys.exc_info()
    log.error(ex.message)


def index():
    return render_template('index.html')

@app.route('/')
def show_article():
    url_to_clean = request.args.get('url_to_clean')
    if not url_to_clean:
	return jsonify(
		'authors'= '', 
		'title'= '',
		'text'= '',
		'keywords'= '',
		'summary'= ''
	)
    else:
    	article = Article(url_to_clean)
	article.download()
	article.parse()

	try:
	  html_string = ElementTree.tostring(article.clean_top_node)
	except:
	  html_string = "Error converting html to string."

	try:
	  article.nlp()
	except:
	  log.error("Couldn't process with NLP")

	a = {
		  'html': html_string, 
		 'authors': str(', '.join(article.authors)), 
		 'title': article.title,
		 'text': article.text,
		 'top_image': article.top_image,
		 'videos': str(', '.join(article.movies)),
		 'keywords': str(', '.join(article.keywords)),
		 'summary': article.summary
		 }
        return jsonify(
		'authors'= str(', '.join(article.authors)), 
		'title'= article.title,
		'text'= article.text,
		'keywords'= str(', '.join(article.keywords)),
		'summary'= article.summary
	)
    

@@ -61,16 +61,25 @@
  url_for
+, jsonify
 %0Afrom ne
@@ -681,19 +681,8 @@
     
-else:%0A    %09
 arti
@@ -709,17 +709,20 @@
 _clean)%0A
-%09
+    
 article.
@@ -732,17 +732,20 @@
 nload()%0A
-%09
+    
 article.
@@ -753,23 +753,29 @@
 arse()%0A%0A
-%09
+    
 try:%0A
-%09
+    
   html_s
@@ -827,25 +827,28 @@
 p_node)%0A
-%09
+    
 except:%0A
 %09  html_
@@ -839,17 +839,20 @@
 except:%0A
-%09
+    
   html_s
@@ -899,15 +899,21 @@
 .%22%0A%0A
-%09
+    
 try:%0A
-%09
+    
   ar
@@ -928,17 +928,20 @@
 p()%0A
-%09
+    
 except:%0A
 %09  l
@@ -936,17 +936,20 @@
 except:%0A
-%09
+    
   log.er
@@ -986,16 +986,18 @@
 %22)%0A%0A
-%09
+    
 a = %7B%0A
-%09
 %09  '
@@ -1017,17 +1017,16 @@
 tring, %0A
-%09
 %09 'autho
@@ -1064,17 +1064,16 @@
 ors)), %0A
-%09
 %09 'title
@@ -1090,17 +1090,16 @@
 .title,%0A
-%09
 %09 'text'
@@ -1114,17 +1114,16 @@
 e.text,%0A
-%09
 %09 'top_i
@@ -1148,17 +1148,16 @@
 _image,%0A
-%09
 %09 'video
@@ -1192,17 +1192,16 @@
 vies)),%0A
-%09
 %09 'keywo
@@ -1240,17 +1240,16 @@
 ords)),%0A
-%09
 %09 'summa
@@ -1273,17 +1273,16 @@
 ary%0A
-%09
 %09 %7D%0A    
     
@@ -1277,20 +1277,16 @@
 %09 %7D%0A    
-  
-  
 return j
@@ -1285,33 +1285,32 @@
 return jsonify(%0A
-%09
 %09'authors'= str(
@@ -1339,17 +1339,16 @@
 ors)), %0A
-%09
 %09'title'
@@ -1364,17 +1364,16 @@
 .title,%0A
-%09
 %09'text'=
@@ -1387,17 +1387,16 @@
 e.text,%0A
-%09
 %09'keywor
@@ -1434,17 +1434,16 @@
 ords)),%0A
-%09
 %09'summar
@@ -1462,16 +1462,14 @@
 summary%0A
-%09)%0A
     
+)
 %0A

Update __init__.py