当前位置:首页>python>Python之Flask开发框架(第二篇

Python之Flask开发框架(第二篇

  • 2026-04-21 06:33:44
Python之Flask开发框架(第二篇

在上一篇教程中,我们掌握了 Flask 的基础知识,包括安装、第一个应用、路由和视图函数。本篇将带领大家进入 Flask 开发的更核心领域:模板渲染表单处理 和 数据库操作。通过这些内容,你将能够构建出功能完整、交互友好且具备数据持久化能力的 Web 应用。


1. 模板渲染

在实际项目中,我们通常不会在视图函数中直接返回 HTML 字符串,而是将 HTML 代码放在独立的模板文件中,并通过模板引擎动态填充数据。Flask 默认使用 Jinja2 模板引擎。

1.1 基本模板语法

首先,在项目根目录下创建 templates 文件夹,用于存放所有模板文件。创建一个简单的模板 index.html

<!DOCTYPEhtml>
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>Hello, {{ name }}!</h1>
</body>
</html>

在视图函数中,使用 render_template 函数渲染模板并传递参数:

from flask import render_template

@app.route('/')
defindex():
return render_template('index.html', title='Home', name='Alice')

Jinja2 支持多种语法:

  • 变量
    {{ variable }}
  • 控制结构
    {% if user %}
        <p>Hello, {{ user }}</p>
    {% else %}
        <p>Hello, Guest</p>
    {% endif %}

    {% for item in items %}
        <li>{{ item }}</li>
    {% endfor %}
  • 过滤器
    :通过 | 对变量进行格式化,如 {{ name|upper }}{{ date|datetime }}(需自定义)。
  • :类似函数,可复用模板片段:
    {% macro input(name, value='', type='text') %}
        <input type="{{ type }}" name="{{ name }}" value="{{ value }}">
    {% endmacro %}

1.2 模板继承

模板继承是 Jinja2 最强大的功能之一,可以避免重复代码。定义一个基础模板 base.html

<!DOCTYPEhtml>
<html>
<head>
<title>{% block title %}{% endblock %} - My App</title>
</head>
<body>
<header>
<h1>My App</h1>
</header>
<main>
        {% block content %}{% endblock %}
</main>
<footer>
<p>&copy; 2023</p>
</footer>
</body>
</html>

子模板通过 extends 继承,并填充 block

{% extends "base.html" %}

{% block title %}Home{% endblock %}

{% block content %}
<p>Welcome to the homepage!</p>
{% endblock %}

1.3 静态文件管理

静态文件(CSS、JS、图片)应放在 static 文件夹中。在模板中,使用 url_for('static', filename='style.css') 生成正确路径:

<linkrel="stylesheet"href="{{ url_for('static', filename='style.css') }}">

2. 表单处理

表单是用户与 Web 应用交互的主要方式。Flask 本身提供了基础的请求数据处理,但推荐使用 Flask-WTF 扩展来简化表单创建、验证和 CSRF 保护。

2.1 安装 Flask-WTF

pip install flask-wtf

2.2 定义表单类

表单类继承自 FlaskForm,字段类型由 WTForms 提供。创建一个简单的登录表单:

from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, SubmitField
from wtforms.validators import DataRequired, Email, Length

classLoginForm(FlaskForm):
    email = StringField('Email', validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired(), Length(min=6)])
    submit = SubmitField('Login')

2.3 在视图中使用表单

在视图函数中创建表单实例,并检查 validate_on_submit() 来处理提交。

from flask import render_template, redirect, url_for

@app.route('/login', methods=['GET','POST'])
deflogin():
    form = LoginForm()
if form.validate_on_submit():
# 表单验证通过,处理登录逻辑
        email = form.email.data
        password = form.password.data
# 实际开发中应验证数据库中的用户
return redirect(url_for('index'))
return render_template('login.html', form=form)

2.4 在模板中渲染表单

Jinja2 可以方便地渲染表单字段和错误信息:

{% extends "base.html" %}

{% block content %}
<formmethod="POST"action="">
        {{ form.hidden_tag() }}  <!-- 生成 CSRF token -->
<div>
            {{ form.email.label }}<br>
            {{ form.email(size=32) }}<br>
            {% for error in form.email.errors %}
<spanstyle="color: red;">[{{ error }}]</span>
            {% endfor %}
</div>
<div>
            {{ form.password.label }}<br>
            {{ form.password(size=32) }}<br>
            {% for error in form.password.errors %}
<spanstyle="color: red;">[{{ error }}]</span>
            {% endfor %}
</div>
<div>{{ form.submit() }}</div>
</form>
{% endblock %}

2.5 CSRF 保护

Flask-WTF 默认启用 CSRF 保护。你需要在应用配置中设置一个密钥:

app.config['SECRET_KEY']='your-secret-key-here'

表单中的 {{ form.hidden_tag() }} 会生成一个隐藏字段,包含 CSRF 令牌。


3. 数据库操作

Flask 本身不绑定数据库,但推荐使用 Flask-SQLAlchemy 作为 ORM 工具,它简化了数据库操作。我们还会使用 Flask-Migrate 来管理数据库迁移。

3.1 安装扩展

pip install flask-sqlalchemy flask-migrate

3.2 配置数据库

在应用配置中设置数据库 URI(以 SQLite 为例):

app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///app.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False

初始化 SQLAlchemy 和 Migrate:

from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate

db = SQLAlchemy(app)
migrate = Migrate(app, db)

3.3 定义模型

模型类继承自 db.Model,每个类对应一张数据库表。例如,创建一个用户模型:

classUser(db.Model):
id= db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password_hash = db.Column(db.String(128))

def__repr__(self):
returnf'<User {self.username}>'

3.4 数据库迁移

使用 Flask-Migrate 可以自动化地生成数据库迁移脚本,避免手动操作。

初始化迁移仓库(只需一次):

flask db init

生成迁移脚本(当模型改变时):

flask db migrate -m"create user table"

应用迁移到数据库:

flask db upgrade

3.5 基本 CRUD 操作

在视图函数中操作数据库。示例:注册用户

from werkzeug.security import generate_password_hash

@app.route('/register', methods=['GET','POST'])
defregister():
    form = RegistrationForm()
if form.validate_on_submit():
# 检查用户名或邮箱是否已存在
        user = User.query.filter_by(username=form.username.data).first()
if user:
            flash('Username already exists','danger')
return redirect(url_for('register'))

# 创建新用户
        new_user = User(
            username=form.username.data,
            email=form.email.data,
            password_hash=generate_password_hash(form.password.data)
)
        db.session.add(new_user)
        db.session.commit()
        flash('Registration successful!','success')
return redirect(url_for('login'))
return render_template('register.html', form=form)

常用查询方法:

  • 查询所有:User.query.all()
  • 按条件查询:User.query.filter_by(username='alice').first()
  • 获取主键:User.query.get(1)
  • 复杂过滤:User.query.filter(User.email.endswith('@example.com')).all()
  • 分页:User.query.paginate(page=1, per_page=20)

3.6 关系映射

定义一对多关系。例如,一个用户可以有多个文章:

classUser(db.Model):
# ...
    posts = db.relationship('Post', backref='author', lazy='dynamic')

classPost(db.Model):
id= db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(100))
    body = db.Column(db.Text)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
  • db.relationship
     定义在 User 模型上,表示从 User 到 Post 的关系。
  • backref='author'
     使得可以从 Post 对象直接访问 post.author 获取作者。
  • lazy='dynamic'
     表示 user.posts 返回一个查询对象,而不是立即加载所有文章。

多对多关系需要借助关联表。例如,用户和角色:

# 关联表
roles_users = db.Table('roles_users',
    db.Column('user_id', db.Integer, db.ForeignKey('user.id')),
    db.Column('role_id', db.Integer, db.ForeignKey('role.id'))
)

classRole(db.Model):
id= db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True)
    users = db.relationship('User', secondary=roles_users, backref='roles')

4. 蓝图(Blueprint)

当应用规模变大时,将所有路由放在一个文件中会变得混乱。Flask 提供了蓝图来模块化路由和视图。

4.1 定义蓝图

创建一个 auth 蓝图,处理认证相关路由:

# auth.py
from flask import Blueprint, render_template

auth_bp = Blueprint('auth', __name__, url_prefix='/auth')

@auth_bp.route('/login')
deflogin():
return render_template('auth/login.html')

4.2 注册蓝图

在应用工厂中注册蓝图:

defcreate_app():
    app = Flask(__name__)
# ...
from.auth import auth_bp
    app.register_blueprint(auth_bp)
return app

4.3 蓝图中的 url_for

在模板或视图中,使用带蓝图名的 url_for

url_for('auth.login')# 生成 /auth/login

5. 错误处理

Flask 允许自定义错误页面,提升用户体验。

5.1 使用 errorhandler 装饰器

@app.errorhandler(404)
defpage_not_found(e):
return render_template('404.html'),404

@app.errorhandler(500)
definternal_server_error(e):
return render_template('500.html'),500

5.2 在蓝图中自定义错误

蓝图也可以有自己的错误处理器,但作用范围仅限于该蓝图下的路由。


总结

在本篇教程中,我们学习了:

  1. 模板渲染
    :使用 Jinja2 模板引擎,包括继承、过滤器、静态文件管理。
  2. 表单处理
    :通过 Flask-WTF 定义表单类、验证数据、CSRF 保护。
  3. 数据库操作
    :使用 Flask-SQLAlchemy 定义模型、执行 CRUD、管理关系,并利用 Flask-Migrate 进行数据库版本控制。
  4. 蓝图
    :将应用模块化,便于组织和扩展。
  5. 错误处理
    :自定义错误页面,提升用户友好度。

掌握了这些内容后,你已经具备了构建完整 Web 应用的能力。在第三篇(也是最后一篇)教程中,我们将深入探讨 Flask 的高级主题,包括:中间件与扩展项目部署,并给出一个综合示例,将所学知识串联起来。

请继续关注第三篇,我们将在那里完成 Flask 学习的最后一块拼图。如果你对第二篇有任何疑问,欢迎随时提出。

欢迎关注公众号,感谢对文章的点赞分享喜欢,冉成未来会持续更新前后端开发技术、人工智能技术、IT相关的文章及学习经验、知识分享,未来虽然充满着不确定性,但我们可以不断提升自己,不断为未来做准备,让未来更好的自己成就更美好的未来。

Python之Flask开发框架(第一篇)

Python之FastAPI 开发知识(第五篇)

Python之FastAPI 开发知识(第四篇)

FastAPI 开发知识(第三篇)

FastAPI 开发知识(第二篇)

FastAPI 开发知识(第一篇)

Django 基础入门教程(第五篇)

Django 基础入门教程(第四篇)

Django 基础入门教程(第三篇)

 Django 基础入门教程(第二篇)

Django 基础入门教程(第一篇)

Python基础系列 | Python之PyQt5基础知识(五)

Python基础系列 | Python之PyQt5基础知识(四)

Python基础系列 | Python之PyQt5基础知识(三)

Python基础系列 | Python之PyQt5基础知识(二)

Python基础系列 | Python之PyQt5基础知识(一)

Python基础系列 | Scrapy框架详细解析

Python基础 | Python之Selenium测试工具集

Python基础系列 | Python爬虫技术(二)

Python基础系列 | Python爬虫技术(一)

Python基础系列 | Python设置pip镜像源

Python基础系列|Python基础知识(六)

Python基础系列|Python基础知识(五)

Python基础系列|Python基础知识(四)

Python基础系列|Python基础知识(三)

Python基础系列|Python基础知识(二)

Python基础系列|Python基础知识(一)

python中列表的处理

Python 基础语法入门:从零开始学习 Python

Windows环境下部署 Python 项目

干货|AI人工智能简介及python环境搭建

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-04-21 12:00:49 HTTP/2.0 GET : https://f.mffb.com.cn/a/484354.html
  2. 运行时间 : 0.125331s [ 吞吐率:7.98req/s ] 内存消耗:5,150.55kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=cb82925113feefadb58d26be0dca7716
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000841s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000871s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000334s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000285s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000570s ]
  6. SELECT * FROM `set` [ RunTime:0.000217s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000599s ]
  8. SELECT * FROM `article` WHERE `id` = 484354 LIMIT 1 [ RunTime:0.000512s ]
  9. UPDATE `article` SET `lasttime` = 1776744049 WHERE `id` = 484354 [ RunTime:0.000760s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000287s ]
  11. SELECT * FROM `article` WHERE `id` < 484354 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000450s ]
  12. SELECT * FROM `article` WHERE `id` > 484354 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.003676s ]
  13. SELECT * FROM `article` WHERE `id` < 484354 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.002916s ]
  14. SELECT * FROM `article` WHERE `id` < 484354 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002527s ]
  15. SELECT * FROM `article` WHERE `id` < 484354 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.007821s ]
0.129246s