This repository was archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
35 lines (28 loc) · 1.59 KB
/
application.py
File metadata and controls
35 lines (28 loc) · 1.59 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
from flask import Flask, render_template, request, json
from lxml import html
import requests
import http.client
import urllib.request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
conservativeNewsSources = ['foxnews.com', 'newyorkpost', 'dailymail.com', 'infowars.com', 'forbes.com', 'nationalreview.com', 'wnd.com', 'townhall.com', 'breitbart.com']
liberalNewsSources = ['abcnews.go.com', 'usatoday.com', 'latimes.com', 'wsj', 'politico.com', 'telemundo.com', 'bloomberg.com', 'wp.com', 'nyt.com', 'theatlantic.com', 'wired.com', 'news.vice.com', 'cbsnews.com', 'msnbc.com', 'bbcnews.com', 'time.com', 'nbcnews.com']
centristNewsSources = ['c-span', 'apnews.com', 'upi', 'thehill.com', 'npr.org', 'reuters.com', 'militarytimes.com']
if request.method == 'GET':
return render_template('index.html')
elif request.method == 'POST':
websiteAddress = str(request.form['websiteAddress'])
topic = str(request.form['topic'])
websiteLean = 'unknown'
if any(x in websiteAddress.lower() for x in conservativeNewsSources):
websiteLean = 'conservative'
elif any(x in websiteAddress.lower() for x in liberalNewsSources):
websiteLean = 'liberal'
elif any(x in websiteAddress.lower() for x in centristNewsSources):
websiteLean = 'centrist'
else:
websiteLean = 'other'
title = ''
return render_template('evaluation.html', topic=topic, websiteLean=websiteLean, title=title, websiteAddress=websiteAddress)
app.run(debug=False, host='0.0.0.0')