-2

This isn't a duplicate question. I've updated the flask code with the answers in the similar questions, but it still isn't working. I'm very new to flask, html and python, so I really do need help. I've probably seen my answer somewhere but haven't recognised it.

The code below doesn't render the index.html template. Instead, I get a HTTP 500 error (jinja2.exceptions.TemplateSyntaxError: expected token ',', got 'string'). I think the problem is in the .html file because when I render other index.html templates without changing my app.py code, the html template is rendered.

Here's the code in app.py

from flask import Flask, render_template, request, session, abort

app = Flask(__name__)
app.static_folder = 'static'


@app.route('/', methods=['GET'])
def test():
    resp = make_response(render_template('index.html'))
    return resp


@app.route('/getTenants', methods=['GET'])
def dummy():
    data = ['Black', 'Blue', 'White', 'Pink']
    return jsonify(results=data)


if __name__ == "__main__":
    app.run(debug=True)

Here's the code in index.html

<!DOCTYPE html>
<html lang="en" ng-app="app">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
    <link rel="shortcut icon" href="{{ url_for('static', filename='img/favicon.ico') }}">

    <title>Create Contract</title>

    <!--  CSS    -->
    <link href="{{ url_for('static', filename= 'css/common.min.css') }}" rel="stylesheet" />
    <link href="{{ url_for('static', filename= 'css/simple-line-icons.css') }}" rel="stylesheet" />
    <link href="{{ url_for('static', filename= 'css/style.css') }}" rel="stylesheet" />

<head>

<body>
<!-- Spinner -->
<div class="spinner global" ng-class="{'showing' : loading }"><div class="spinner-icon"></div></div>

<!-- Main View -->
<div ui-view></div>

<!-- Awesome Angular -->
<script src="{{ url_for('static', filename='js/libs/angular.min.js') }}"></script>

<!-- AngularJS plugins -->
<script src="{{ url_for('static', filename='js/libs/ui-bootstrap.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/angular-ui-router.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/libs/ocLazyLoad.min.js') }}"></script>
<script src="{{ url_for('static', filename=js/libs/loading-bar.min.js') }}"></script>

<!-- App scripts -->
<script src="{{ url_for('static', filename='js/app.js') }}"></script>
<script src="{{ url_for('static', filename='js/routes.js') }}"></script>
<script src="{{ url_for('static', filename='js/services.js') }}"></script>
<script src="{{ url_for('static', filename='js/controllers.js') }}"></script>
<script src="{{ url_for('static', filename='js/directives.js') }}"></script>
</body>

</html>

The traceback error is jinja2.exceptions.TemplateSyntaxError: expected token ',', got 'string'

Can someone please let me know what I'm doing wrong?

DeeChok
  • 359
  • 1
  • 3
  • 7

1 Answers1

0

Line 33 in your code index.html snippet:

Right after filename attribute paste '

Yaroslav Surzhikov
  • 1,568
  • 1
  • 11
  • 16