Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 947 Bytes
from flask import Flask, render_template
import random
import pickle
import io
baldwin = io.open('letter-from-a-region-baldwin.txt', encoding='utf-8').read()
spencer_bios = pickle.load(open('bios.pickle', 'rb'))
app = Flask(__name__)
@app.route('/white')
def white():
white_lines = []
lines = baldwin.split('.')
for line in lines:
if line.lower().find('white'.lower()) != -1:
white_lines.append(line)
white_bios = []
for bio in spencer_bios:
if bio == '':
spencer_bios.remove(bio)
if bio == ' ':
spencer_bios.remove(bio)
words = bio.split()
for word in words:
if word.lower().find('white'.lower()) != -1:
white_bios.append(bio)
picker1 = random.randrange(0, len(white_bios), 1)
picker2 = random.randrange(0, len(white_lines), 1)
return render_template("whiteness.html", rs_follower=white_bios[picker1], baldwin=white_lines[picker2])
if __name__ == '__main__':
app.run()