我的HTML表格未显示,我按照确切的说明进行操作

时间:2020-10-22 03:57:18

标签: html visual-studio html-table

我按照确切的说明从https://www.youtube.com/watch?v=Z1RJmh_OqeA制作了一张桌子,但是我的桌子没有出现。我还在代码中使用{%block%}并使用虚拟环境。基本上,我的代码与指令完全相同,但结果却不同

这是我的app.py

from flask import Flask, url_for, render_template
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
db = SQLAlchemy(app)

class Todo(db.Model):
  id = db.Column(db.Integer, primary_key=True)
  content = db.Column(db.String(200), nullable=False)
  completed = db.Column(db.Integer, default=0)
  date_created = db.Column(db.DateTime, default=datetime.utcnow)

  def __repr__(self):
    return '<Task %r>' %self.id 

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

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

这是我的base.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name='viewport' content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie-edge">
    {% block head %}{% endblock %}
  </head>
  <body>
    {% block body %}{% endblock %}
  </body>
</html>

和index.html

{% extends 'base.html' %}

{% block head %}

{% endblock %}

{% block body %}
<div class="content">  
  <h1>Task Master</h1>

  <table>
    <tr>
      <th>Task</th>
      <th>Added</th>
      <th>Action</th>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td>
        <a href="">Delete</a>
        <br>
        <a href="">Update</a>
      </td>
    </tr>
  </table>
</div>
{% endblock %}

和来自本地主机的视图

the view

我使用VCS对其进行编码。谢谢

0 个答案:

没有答案