I am just getting started with Python, Flask and Neo4j. I am struggling with trying to pass a parameter from a url to a cypher query via py2neo.
I have tried a number of suggestions from the forums, tutorials and examples on github but have not managed to get this to work and was hoping someone could point me in the right direction.
This is views.py
#Single Comic
@app.route('/comic/<issue>/')
def comic(issue):
# Get comic
issue = comics.get_issue(issue)
return render_template('issue.html', issue=issue)
This is my models.py (if I hard code the issue number into the query it shows correctly)
class comics:
def __init__(self, issue):
self.issue = issue;
def get_issue(issue):
query = '''
MATCH (c:Comic) WHERE c.Issue=$issue
RETURN c.Issue as issue, c.Title as title
'''
return graph.run(query)
This is the issue.html template
{% extends "base.html" %}
{% block content %}
{% for row in issue %}
<h1>{{ row.issue }}: {{ row.title }} </h1>
<img src="/static/comics/{{ row.issue }}.png" alt="{{ row.title }}">
{% endfor %}
{% endblock %}
When I try to browse www.mydomain.com/comic/1 I get a "Parameter Missing: Expected parameter(s): issue" error
Many thanks