{"id":13571619,"url":"https://github.com/bosombaby/flask-course","last_synced_at":"2025-04-04T08:31:44.369Z","repository":{"id":189337872,"uuid":"680500069","full_name":"bosombaby/flask-course","owner":"bosombaby","description":"Flask 是一个使用 Python 编写的轻量级 Web 应用框架。它基于 Werkzeug WSGI 工具箱和 Jinja2 模板引擎，提供了简单易用的 API，可以帮助开发者快速构建 Web 应用程序。Flask 框架具有灵活性和可扩展性，可以根据需要添加各种插件和扩展，例如数据库集成、表单验证、用户认证等。Flask 框架还提供了丰富的文档和社区支持，使得开发者可以轻松地学习和使用它。","archived":false,"fork":false,"pushed_at":"2023-08-21T09:21:50.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-05T04:34:15.417Z","etag":null,"topics":["css3","flask","html5","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bosombaby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-19T12:53:38.000Z","updated_at":"2023-09-02T08:39:13.000Z","dependencies_parsed_at":"2024-01-14T03:51:11.079Z","dependency_job_id":"76ec8b0a-0c03-4eeb-80ac-a010cca7a244","html_url":"https://github.com/bosombaby/flask-course","commit_stats":null,"previous_names":["bosombaby/flask-course"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bosombaby%2Fflask-course","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bosombaby%2Fflask-course/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bosombaby%2Fflask-course/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bosombaby%2Fflask-course/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bosombaby","download_url":"https://codeload.github.com/bosombaby/flask-course/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247147390,"owners_count":20891685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css3","flask","html5","python3"],"created_at":"2024-08-01T14:01:03.895Z","updated_at":"2025-04-04T08:31:39.360Z","avatar_url":"https://github.com/bosombaby.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# 一、前言\nFlask 是一个使用 Python 编写的轻量级 Web 应用框架。它基于 Werkzeug WSGI 工具箱和 Jinja2 模板引擎，提供了简单易用的 API，可以帮助开发者快速构建 Web 应用程序。Flask 框架具有灵活性和可扩展性，可以根据需要添加各种插件和扩展，例如数据库集成、表单验证、用户认证等。Flask 框架还提供了丰富的文档和社区支持，使得开发者可以轻松地学习和使用它。\n\n![4.png](https://cdn.nlark.com/yuque/0/2023/png/27367619/1692609583997-1727dc21-f64f-4726-8895-e4697a4a592f.png#averageHue=%23f5f4f2\u0026clientId=u104d5310-6296-4\u0026from=ui\u0026id=u483a6e2b\u0026originHeight=870\u0026originWidth=945\u0026originalType=binary\u0026ratio=1.25\u0026rotation=0\u0026showTitle=false\u0026size=58857\u0026status=done\u0026style=none\u0026taskId=u57ee62ab-0c8b-47d7-aa9b-c14683480af\u0026title=)\n**项目源码**：[flask-course](https://github.com/bosombaby/flask-course)\n# 二、资源收集\n## 2.1 在线教程\n**官网**\n[GitHub - pallets/flask: The Python micro framework for building web applications.](https://github.com/pallets/flask)\n\n**中文教程**\n[Flask 入门教程](https://tutorial.helloflask.com/)\n使用版本：\n\n- flask 2.1.3\n- python \u003e 3.6\n## 2.2 环境配置\n[Flask--如何在pycharm中导入并运行flask项目_此生小会的博客-CSDN博客](https://blog.csdn.net/cckavin/article/details/83746927)\n[pycharm设置保存时自动格式化代码（Auto Reformat Code）_pycharm保存自动格式化_粒米LALA的博客-CSDN博客](https://blog.csdn.net/qq_41906934/article/details/124631826)\n[新手必会，pycharm的调试功能(史上最详篇)](https://zhuanlan.zhihu.com/p/62610785)\n# 三、入门\n[Flask 入门教程 - 第 2 章：Hello, Flask!](https://tutorial.helloflask.com/hello/)\n[Flask 入门教程 - 第 3 章：模板](https://tutorial.helloflask.com/template/)\n# 四、静态文件\n\n[Flask 入门教程 - 第 4 章：静态文件](https://tutorial.helloflask.com/static/)\n# 五、数据库\n\n**虚拟数据生成**：[https://github.com/joke2k/faker](https://github.com/joke2k/faker)\n[SQLAlchemy](https://www.sqlalchemy.org/)\nSQLAlchemy是一个Python库，用于在Python应用程序中使用关系型数据库。它提供了一组工具和API，使得在Python中使用关系型数据库变得更加容易和灵活。\nSQLAlchemy的主要特点包括：\n\n- ORM支持：SQLAlchemy提供了一个ORM(Object-Relational Mapping)框架，使得在Python中使用关系型数据库变得更加容易和直观。\n- 多数据库支持：SQLAlchemy支持多种关系型数据库，包括MySQL、PostgreSQL、Oracle、Microsoft SQL Server等。\n- 事务支持：SQLAlchemy支持完整的事务性，包括ACID属性(原子性、一致性、隔离性和持久性)。\n- 数据库连接池：SQLAlchemy提供了一个数据库连接池，可以管理数据库连接的创建和销毁，从而提高应用程序的性能和可伸缩性。\n- SQL表达式语言：SQLAlchemy提供了一个SQL表达式语言，使得在Python中编写SQL语句变得更加容易和安全。\n\n使用SQLAlchemy，您可以在Python应用程序中轻松地执行各种数据库操作，包括创建、读取、更新和删除数据。您可以使用ORM框架来映射Python对象和数据库表，从而使得在Python中操作数据库变得更加直观和易于维护。\n# 六、模板优化\n[Flask 入门教程 - 第 6 章：模板优化](https://tutorial.helloflask.com/template2/)\n\n**核心：模板的继承**\n# 七、表单\n[Flask 入门教程 - 第 7 章：表单](https://tutorial.helloflask.com/form/)\n\n- 默认和入口文件放在同一个文件夹下面\n- 名称为templates\n# 八、用户认证\n[Flask 入门教程 - 第 8 章：用户认证](https://tutorial.helloflask.com/login/)\n## 8.1 werkzeug\n\n- Werkzeug 是一个 Python Web 工具库，提供了一些用于构建 Web 应用程序的基础组件，包括路由、请求和响应对象、中间件、调试工具等。\n- Werkzeug 的设计目标是提供简单、灵活、可扩展的工具，以便开发人员可以根据自己的需求构建定制化的 Web 应用程序。\n## 8.2 flask_login\nFlask-Login 是一个 Flask 扩展，用于处理用户认证和会话管理。下面是一些 Flask-Login 的特点：\n\n- 提供了一组用于处理用户登录、注销、记住用户等功能的工具和约定。\n- 轻松地集成到 Flask 应用程序中，只需要安装扩展并进行简单的配置即可。\n- 支持多种用户模型和认证方法，可以根据应用程序的需求进行定制。\n- 处理用户会话和 cookie，以便在用户访问应用程序时自动登录或注销。\n- 处理用户权限和角色，以便在应用程序中实现访问控制和权限管理。\n- 处理用户会话的保护和安全，以防止会话劫持和其他安全问题。\n- 处理用户密码的加密和验证，以确保用户密码的安全性。\n- 处理用户记住登录状态的功能，以便在用户关闭浏览器后仍然保持登录状态。\n# 九、代码测试\n## 9.1 unittest\n[unittest教程_w3cschool](https://www.w3cschool.cn/unittest/)\n\n- unittest 是 Python 标准库中的一个单元测试框架，用于编写和运行单元测试。\n- 单元测试是一种测试方法，用于测试代码中的最小可测试单元，通常是函数或方法。\n- unittest 提供了一组用于编写和运行单元测试的工具和约定，包括测试用例、测试套件、测试运行器等。\n- 使用 unittest 可以帮助开发人员编写更可靠、更健壮的代码，并确保代码的正确性和稳定性。\n- unittest 还支持测试覆盖率、测试报告等高级功能，可以帮助开发人员更好地了解代码的测试情况。\n## 9.2 coverage\n![1.png](https://cdn.nlark.com/yuque/0/2023/png/27367619/1692608904333-aa9c1e24-0588-4c52-b66d-f0e408dcfaf3.png#averageHue=%23f9f8f7\u0026clientId=u104d5310-6296-4\u0026from=ui\u0026id=u73ad2045\u0026originHeight=629\u0026originWidth=1553\u0026originalType=binary\u0026ratio=1.25\u0026rotation=0\u0026showTitle=false\u0026size=64312\u0026status=done\u0026style=none\u0026taskId=ud076015d-2ad5-42a5-bae2-ecd0732c82f\u0026title=)\n\n![2.png](https://cdn.nlark.com/yuque/0/2023/png/27367619/1692608910240-c175e695-bd3e-4859-a985-4a726b3347ce.png#averageHue=%23faf9f8\u0026clientId=u104d5310-6296-4\u0026from=ui\u0026id=u9040aa12\u0026originHeight=302\u0026originWidth=788\u0026originalType=binary\u0026ratio=1.25\u0026rotation=0\u0026showTitle=false\u0026size=23411\u0026status=done\u0026style=none\u0026taskId=u445e1c9b-09cf-4e80-b75c-15a8c7a82d8\u0026title=)\n[Python代码覆盖率工具coverage使用教程 - ☆星空物语☆ - 博客园](https://www.cnblogs.com/songzhenhua/p/13194232.html)\n\n- 可以帮助开发人员了解哪些代码被测试覆盖，哪些代码没有被测试覆盖，以及测试用例的质量和完整性。\n- 可以生成各种格式的测试覆盖率报告，包括 HTML 报告、XML 报告、JSON 报告等。\n- 可以与多种测试框架集成，包括 unittest、pytest、nose 等。\n- 可以计算语句、分支、函数和行覆盖率等多种覆盖率指标。\n- 可以忽略指定的文件、目录、代码行等，以便更精确地计算覆盖率。\n- 可以在命令行或配置文件中设置各种选项，以便更灵活地使用。\n- 是一个开源工具，可以免费使用，并且有活跃的社区支持和维护。\n# 十、代码重构\n[Flask 入门教程 - 第 10 章：组织你的代码](https://tutorial.helloflask.com/organize/)\n\n[python中遇到循环import即circular import的问题原理剖析及解决方案_幸福清风的博客-CSDN博客](https://blog.csdn.net/xun527/article/details/108637094)\n\n在 Python 中，循环导入通常是指两个或多个模块相互导入，导致无法解析模块依赖关系的问题。这种情况通常会导致 ImportError 异常或其他奇怪的行为。为了避免循环导入，可以尝试以下几种方法：\n\n1. 重构代码，将循环依赖关系消除。\n2. 将导入语句移动到函数内部，以延迟导入。\n3. 将导入语句移动到模块底部，以确保所有依赖项都已定义。\n4. 使用绝对导入语法，以避免相对导入语法的问题。\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosombaby%2Fflask-course","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbosombaby%2Fflask-course","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosombaby%2Fflask-course/lists"}