<commit_before>######################################
# File Name : web_version.py
# Author : <NAME>
# Creation Date : 11-21-2015
######################################
import pandas as pd
from flask import Flask
from flask import request, render_template, url_for
import indeed_scrape
import jinja2
from bokeh.embed import components
from bokeh.plotting import figure, output_file
from bokeh.util.string import encode_utf8
from bokeh.charts import Bar

input_template = jinja2.Template('''
<!DOCTYPE html>
<html lang="en">
<head>
    <title>indeed skill scraper</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>INDEED.COM JOB OPENINGS SKILL SCRAPER</h1>
    <form action="/main/" method="POST">
        Enter keywords you normally use to search for openings on indeed.com<br>
        <input type="text" name="kw"><br>
        Enter zipcodes<br>
        <input type="text" name="zipcodes"><br>
        <input type="submit" value="Submit" name="submit">
    </form>
</body>
</html>''')

output_template = jinja2.Template("""
<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>indeed skill scraper results</title>
    <meta charset="UTF-8">
</head>

<link
    href="http://cdn.pydata.org/bokeh/release/bokeh-0.9.0.min.css"
    rel="stylesheet" type="text/css"
>
<script
    src="http://cdn.pydata.org/bokeh/release/bokeh-0.9.0.min.js"
></script>

<body>

    <h1>INDEED.COM JOB OPENINGS SKILL SCRAPER RESULTS</h1>

    {{ script }}

    {{ div }}

</body>

</html>
""")

app = Flask(__name__)

def plot_fig(df, num):

    title_string = "Analysis of %i Postings" % num

    p = Bar(df, 'kw',
            values='count',
            title=title_string,
            title_text_font_size='15',
            color='blue',
            xlabel="keywords",
            ylabel="Count")

    return p

@app.route('/', methods=['POST'] )
def get_keywords():
    return input_template.render()

@app.route('/main/', methods=['POST'])
def main():
    kws = request.form['kw']
    zips = request.form['zipcodes']
    return output_template.render(scripts="testing", div='testing')
#    kw, count, num, cities = run_analysis(kws, zips)
#
#    df = pd.DataFrame(columns=['keywords','counts', 'cities'])
#
#    df['kw'] = kw
#    df['count'] = count
#    df['cities'] = cities
#
#    p = plot_fig(df, num)
#    script, div = components(p)
#
#    html = output_template.render(script=script, div=div)
#
#    return encode_utf8(html)

def run_analysis(keywords, zipcodes):

    ind = indeed_scrape.Indeed()
    ind.query = keywords
    ind.stop_words = "and"
    ind.add_loc = zipcodes

    ind.main()<commit_msg>removed method from first template render<commit_after>######################################
# File Name : web_version.py
# Author : <NAME>
# Creation Date : 11-21-2015
######################################
import pandas as pd
from flask import Flask
from flask import request, render_template, url_for
import indeed_scrape
import jinja2
from bokeh.embed import components
from bokeh.plotting import figure, output_file
from bokeh.util.string import encode_utf8
from bokeh.charts import Bar

input_template = jinja2.Template('''
<!DOCTYPE html>
<html lang="en">
<head>
    <title>indeed skill scraper</title>
    <meta charset="UTF-8">
</head>
<body>
    <h1>INDEED.COM JOB OPENINGS SKILL SCRAPER</h1>
    <form action="/main/" method="POST">
        Enter keywords you normally use to search for openings on indeed.com<br>
        <input type="text" name="kw"><br>
        Enter zipcodes<br>
        <input type="text" name="zipcodes"><br>
        <input type="submit" value="Submit" name="submit">
    </form>
</body>
</html>''')

output_template = jinja2.Template("""
<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>indeed skill scraper results</title>
    <meta charset="UTF-8">
</head>

<link
    href="http://cdn.pydata.org/bokeh/release/bokeh-0.9.0.min.css"
    rel="stylesheet" type="text/css"
>
<script
    src="http://cdn.pydata.org/bokeh/release/bokeh-0.9.0.min.js"
></script>

<body>

    <h1>INDEED.COM JOB OPENINGS SKILL SCRAPER RESULTS</h1>

    {{ script }}

    {{ div }}

</body>

</html>
""")

app = Flask(__name__)

def plot_fig(df, num):

    title_string = "Analysis of %i Postings" % num

    p = Bar(df, 'kw',
            values='count',
            title=title_string,
            title_text_font_size='15',
            color='blue',
            xlabel="keywords",
            ylabel="Count")

    return p

@app.route('/')
def get_keywords():
    return input_template.render()

@app.route('/main/', methods=['POST'])
def main():
    kws = request.form['kw']
    zips = request.form['zipcodes']
    return output_template.render(scripts="testing", div='testing')
#    kw, count, num, cities = run_analysis(kws, zips)
#
#    df = pd.DataFrame(columns=['keywords','counts', 'cities'])
#
#    df['kw'] = kw
#    df['count'] = count
#    df['cities'] = cities
#
#    p = plot_fig(df, num)
#    script, div = components(p)
#
#    html = output_template.render(script=script, div=div)
#
#    return encode_utf8(html)

def run_analysis(keywords, zipcodes):

    ind = indeed_scrape.Indeed()
    ind.query = keywords
    ind.stop_words = "and"
    ind.add_loc = zipcodes

    ind.main()
{'fraction_non_alphanumeric': 0.1840843720038351, 'fraction_numerical': 0.010354745925215724, 'mean_word_length': 3.5043177892918824, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '56499', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1772, 'n_words': 405}