Javascript未在Flask中执行

时间:2018-09-28 12:38:08

标签: javascript python flask

我正在尝试使jQuery JavaScript在Flask中工作。在我的浏览器中加载html网站时,html代码将按预期方式呈现。相反,通过Flask应用程序加载时,JavaScript似乎无法执行。

我怀疑这可能与脚本的路径有关。但是,我已经用尽了所有的排列尝试。

Python方面:

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端:

<!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>

0 个答案:

没有答案