0

I am trying to get a jQuery JavaScript to work within Flask. When loading the html site in my browser the html-code renders as expected. In contrast, when loading through a Flask application the JavaScript does not seem to execute.

I suspect it may have something to do with the path to the scripts. However, I have run out of permutations to try.

Python side:

from flask import Flask, render_template, flash, request

# App config.
DEBUG = True
app = Flask(__name__)
app.config.from_object(__name__)
app.config['SECRET_KEY'] = '314589pyuwdfdfegkjbn3689'


@app.route("/", methods=['GET', 'POST'])
def index():            
    return render_template('index2.html')


if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)

HTML side:

<!DOCTYPE html>
<html lang="en">
    <head>
        <!-- Bootstrap -->
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <link href="css/jquery.treetable.css" rel="stylesheet">
        <link href="css/jquery.treetable.theme.default.css" rel="stylesheet">
    </head>
<div class="container">
  <br>
    <form method="post">
        <div class="container" style="width:980px;margin:auto;"
            <table class="table table-striped">
            <table>
                <thead>
                    <th>Exception</th>
                </thead>
            <tbody>
                <tr data-tt-id="1">
                    <td>File1</td>
                </tr>
                <tr data-tt-id="1.1" data-tt-parent-id="1">
                    <td>Column1</td>
                </tr>
                <tr data-tt-id="1.1.1" data-tt-parent-id="1.1">
                    <td>Exception1</td>
                </tr>

            </table>
            <input type="submit" value="Submit">
        </div>  
    </form>
  <br>        
</div>
<br>      
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="jquery.treetable.js"></script>
<script>
    $('table').treetable({ expandable: true });
</script>
</body>
</html>
Christian
  • 991
  • 2
  • 13
  • 25

0 Answers0