I have a python script (display_names.py) that displays the list of names in the json file
def search():
with open('business_ten.json') as f:
data=f.read()
jsondata=json.loads(data)
for row in jsondata['rows']:
a=str(row['name'])
yield a
print list(search())
I am trying to call this function in my html file(crawl.html) using flask.
{% extends "layout.html" %}
{% block content %}
<div class="jumbo">
<h2>Welcome to the Rating app<h2>
<h3>This is the home page for the Rating app<h3>
</div>
<body>
<p>{{ myfucntion}}</p>
</body>
{% endblock %}
My routes file is as follows:
from flask import Flask,render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/crawl')
def crawl():
return render_template('crawl.html' , myfucntion=search)
if __name__ == '__main__':
app.run()
This doesnt work and it always gives an error on the html page please help