Django3 + Vue.js 前后端分离书籍添加项目Web开发实战

news2024/11/5 4:59:45

文章目录

        • Django3后端项目创建
        • 切换数据库
        • 创建Django实战项目App
        • 新建Vue.js前端项目

Django3后端项目创建
  1. 创建Django项目,采用Pycharm或者命令行创建皆可。此处,以命令行方式作为演示,项目名为django_vue

django-admin startproject django_vue

项目结构如图所示
在这里插入图片描述
2. 同步数据库文件(Django默认数据库为db.sqlite3),执行同步过程如下:

切换路径到项目目录

cd django_vue

执行同步

python manage.py migrate

PS E:\coding\Django_learn\django_vue> python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
PS E:\coding\Django_learn\django_vue>
  1. 启动Django Server ,验证默认配置是否正常。

python manage.py runserver

PS E:\coding\Django_learn\django_vue> python manage.py runserver             
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
November 03, 2024 - 12:56:21
Django version 5.1.2, using settings 'django_vue.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

[03/Nov/2024 12:56:24] "GET / HTTP/1.1" 200 12068
Not Found: /favicon.ico
[03/Nov/2024 12:56:24] "GET /favicon.ico HTTP/1.1" 404 2212

在这里插入图片描述

切换数据库
  1. Django数据库更换为Mysql

登录mysql

mysql -u root -p

在这里插入图片描述
2. 创建数据库,数据库取名为django_vue_db,并设置字符集为utf-8

mysql> CREATE DATABASE django_vue_db CHARACTER SET utf8;
Query OK, 1 row affected, 1 warning (0.15 sec)
  1. 安装myslqclient

  2. 配置settings.py文件,配置Mysql数据库引擎。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'django_vue_db',
        'USER': 'root',
        'PASSWORD': 'xxxxxxx',
        'HOST': '127.0.0.1',
    }
}
  1. 执行同步操作,将数据迁移到Mysql

python manage.py migrate

S E:\coding\Django_learn\django_vue> python manage.py migrate
>>
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying sessions.0001_initial... OK
  1. 验证是否切库成功,进入到Mysql客户端,查看django初化表是否有生成。
mysql> use django_vue_db;
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_django_vue_db    |
+----------------------------+
| auth_group                 |
| auth_group_permissions     |
| auth_permission            |
| auth_user                  |
| auth_user_groups           |
| auth_user_user_permissions |
| django_admin_log           |
| django_content_type        |
| django_migrations          |
| django_session             |
+----------------------------+
10 rows in set (0.00 sec)
  1. 运行Django Server,重新访问http://localhost:8000
    如果能正常访问,过程没有报错,说明切换数据库已经成功了。
创建Django实战项目App
  1. 创建Django App,进入django_vue项目主目录,输入如下命令:

python manage.py startapp api_test

  1. App创建完成后,目录结构如下所示:
    在这里插入图片描述

并把api_test加入到settings文件中的installed_apps列表里:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'api_test',
]
  1. api_test目录下的models.py里写一个model

from __future__ import unicode_literals
from django.db import models
class Book(models.Model):
    book_name = models.CharField(max_length=128)
    add_time = models.DateTimeField(auto_now_add=True)
 
 
    def __unicode__(self):
        return self.book_name

只有两个字段,书名book_name和添加时间add_time。如果没有指定主键的话Django会自动新增一个自增id作为主键。

  1. api_test目录下的views里我们新增两个接口,一个是show_books返回所有的书籍列表(通过JsonResponse返回能被前端识别的json格式数据),二是add_book接受一个get请求,往数据库里添加一条book数据。
from django.shortcuts import render
from django.views.decorators.http import require_http_methods
from django.core import serializers
from django.http import JsonResponse
import json
 
 
from .models import Book
 
 
@require_http_methods(["GET"])
def add_book(request):
    response = {}
    try:
        book = Book(book_name=request.GET.get('book_name'))
        book.save()
        response['msg'] = 'success'
        response['error_num'] = 0
    except  Exception as e:
        response['msg'] = str(e)
        response['error_num'] = 1
    return JsonResponse(response)
 
 
@require_http_methods(["GET"])
def show_books(request):
    response = {}
    try:
        books = Book.objects.filter()
        response['list'] = json.loads(serializers.serialize("json", books))
        response['msg'] = 'success'
        response['error_num'] = 0
    except  Exception as e:
        response['msg'] = str(e)
        response['error_num'] = 1
    return JsonResponse(response)
  1. api_test目录下,新增一个urls.py文件,把我们新增的两个接口添加到路由里:
from django.conf.urls import url, include
from .views import *
 
 
urlpatterns = [
    url(r"add_book$", add_book, ),
    url(r"show_books$", show_books, ),
]
  1. 我们还要把api_test下的urls添加到项目django_vue下的urls中,才能完成路由:
from django.contrib import admin
from django.urls import path
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import TemplateView
import api_test.urls
 
 
urlpatterns = [
    url(r"^admin/", admin.site.urls),
    url(r'^api/', include(api_test.urls)),
]
  1. 在项目的根目录,输入命令:
python manage.py makemigrations api_test
python manage.py migrate
  1. 查询数据库,看到book表已经自动创建了:
PS E:\coding\Django_learn\django_vue> python manage.py makemigrations api_test
>>
Migrations for 'api_test':
  api_test\migrations\0001_initial.py
    + Create model Book
PS E:\coding\Django_learn\django_vue> python manage.py migrate
>>
Operations to perform:
  Apply all migrations: admin, api_test, auth, contenttypes, sessions
Running migrations:
  Applying api_test.0001_initial... OK

在这里插入图片描述
Django生成的表名将以app名加上model中的类名组合而成。

新建Vue.js前端项目

有关Vue的模块(包括vue)可以使用node自带的npm包管理器安装。推荐使用淘宝的 cnpm 命令行工具代替默认的 npm

npm install -g cnpm --registry=https://registry.npm.taobao.org
  1. 先用cnpm安装vue-cli脚手架工具(vue-cli是官方脚手架工具,能迅速帮你搭建起vue项目的框架):

cnpm install -g vue-cli

PS E:\coding\Django_learn\django_vue> cnpm install -g vue-cli
>>
Downloading vue-cli to C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli_tmp
Copying C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli_tmp\.store\vue-cli@2.9.6\node_modules\vue-cli to C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli
Installing vue-cli's dependencies to C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli/node_modules
[1/20] uid@0.0.2 installed at node_modules\.store\uid@0.0.2\node_modules\uid
[2/20] commander@^2.9.0 installed at node_modules\.store\commander@2.20.3\node_modules\commander
[3/20] semver@^5.1.0 installed at node_modules\.store\semver@5.7.2\node_modules\semver
[4/20] tildify@^1.2.0 installed at node_modules\.store\tildify@1.2.0\node_modules\tildify
[5/20] user-home@^2.0.0 installed at node_modules\.store\user-home@2.0.0\node_modules\user-home
[6/20] validate-npm-package-name@^3.0.0 installed at node_modules\.store\validate-npm-package-name@3.0.0\node_modules\validate-npm-package-name
[7/20] coffee-script@1.12.7 installed at node_modules\.store\coffee-script@1.12.7\node_modules\coffee-script
[8/20] multimatch@^2.1.0 installed at node_modules\.store\multimatch@2.1.0\node_modules\multimatch
[9/20] minimatch@^3.0.0 installed at node_modules\.store\minimatch@3.1.2\node_modules\minimatch
[10/20] read-metadata@^1.0.0 installed at node_modules\.store\read-metadata@1.0.0\node_modules\read-metadata
[11/20] consolidate@^0.14.0 installed at node_modules\.store\consolidate@0.14.5\node_modules\consolidate
[12/20] chalk@^2.1.0 installed at node_modules\.store\chalk@2.4.2\node_modules\chalk
[13/20] rimraf@^2.5.0 installed at node_modules\.store\rimraf@2.7.1\node_modules\rimraf
[14/20] ora@^1.3.0 installed at node_modules\.store\ora@1.4.0\node_modules\ora
[15/20] request@^2.67.0 installed at node_modules\.store\request@2.88.2\node_modules\request
[16/20] download-git-repo@^1.0.1 installed at node_modules\.store\download-git-repo@1.1.0\node_modules\download-git-repo
[17/20] handlebars@^4.0.5 installed at node_modules\.store\handlebars@4.7.8\node_modules\handlebars
[18/20] metalsmith@^2.1.0 installed at node_modules\.store\metalsmith@2.6.3\node_modules\metalsmith
[19/20] async@^2.4.0 installed at node_modules\.store\async@2.6.4\node_modules\async
[20/20] inquirer@^6.0.0 installed at node_modules\.store\inquirer@6.5.2\node_modules\inquirer
deprecate consolidate@^0.14.0 Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
deprecate rimraf@^2.5.0 Rimraf versions prior to v4 are no longer supported
deprecate request@^2.67.0 request has been deprecated, see https://github.com/request/request/issues/3142
deprecate rimraf@2.7.1 › glob@^7.1.3 Glob versions prior to v9 are no longer supported
deprecate request@2.88.2 › har-validator@~5.1.3 this library is no longer supported
deprecate rimraf@2.7.1 › glob@7.2.3 › inflight@^1.0.4 This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
deprecate request@2.88.2 › uuid@^3.3.2 Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
Run 1 script(s) in 1s.
All packages installed (231 packages installed from npm registry, used 12s(network 12s), speed 514.2KB/s, json 222(1.25MB), tarball 4.73MB, manifests cache hit 0, etag hit 0 / miss 0)
[vue-cli@2.9.6] link C:\Users\lenovo\AppData\Roaming\npm\vue@ -> C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli\bin\vue
[vue-cli@2.9.6] link C:\Users\lenovo\AppData\Roaming\npm\vue-init@ -> C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli\bin\vue-init
[vue-cli@2.9.6] link C:\Users\lenovo\AppData\Roaming\npm\vue-list@ -> C:\Users\lenovo\AppData\Roaming\npm\node_modules\vue-cli\bin\vue-list
  1. 安装好后,在django_vue项目根目录下,新建一个前端工程目录:

vue-init webpack frontend

PS E:\coding\Django_learn\django_vue> vue-init webpack frontend
>>

? Project name frontend
? Project description A Vue.js project
? Author aliyun5171063201 <19377056@buaa.edu.cn>
? Vue build standalone      
? Install vue-router? Yes
? Use ESLint to lint your code? Yes
? Pick an ESLint preset Standard
? Set up unit tests Yes
? Pick a test runner jest
? Setup e2e tests with Nightwatch? Yes
? Should we run `npm install` for you after the project has been created? (recommended) npm

   vue-cli · Generated "frontend".


# Installing project dependencies ...
# ========================

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm warn deprecated rimraf@2.7.1: Rimraf versions prior to v4 are no longer supported
npm warn deprecated har-validator@5.1.5: this library is no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm warn deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm warn deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm warn deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm warn deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
npm warn deprecated acorn-dynamic-import@2.0.2: This is probably built in to whatever tool you're using. If you still 
need it... idk
npm warn deprecated consolidate@0.14.5: Please upgrade to consolidate v1.0.0+ as it has been modernized with several long-awaited fixes implemented. Maintenance is supported by Forward Email at https://forwardemail.net ; follow/watch https://github.com/ladjs/consolidate for updates and release changelog
npm warn deprecated json3@3.3.2: Please use the native JSON object instead of JSON 3
npm warn deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm warn deprecated copy-concurrently@1.0.5: This package is no longer supported.
npm warn deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142   
npm warn deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm warn deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
npm warn deprecated q@1.4.1: You or someone you depend on is using Q, the JavaScript Promise library that gave JavaScript developers strong feelings about promises. They can almost certainly migrate to the native JavaScript promise now. Thank you literally everyone for joining me in this bet against the odds. Be excellent to each other.
npm warn deprecated
npm warn deprecated (For a CapTP with native promises, see @endo/eventual-send and @endo/captp)
npm warn deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead
npm warn deprecated domexception@1.0.1: Use your platform's native DOMException instead
npm warn deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.       
npm warn deprecated left-pad@1.3.0: use String.prototype.padStart()
npm warn deprecated fs-write-stream-atomic@1.0.10: This package is no longer supported.
npm warn deprecated move-concurrently@1.0.1: This package is no longer supported.
npm warn deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm warn deprecated sane@2.5.2: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm warn deprecated eslint-loader@1.9.0: This loader has been deprecated. Please use eslint-webpack-plugin
npm warn deprecated chromedriver@2.46.0: Chromedriver download url has changed. Use version 114.0.2 or newer.
npm warn deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm warn deprecated html-webpack-plugin@2.30.1: out of support
npm warn deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm warn deprecated rimraf@2.6.3: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.0.5: Glob versions prior to v9 are no longer supported
npm warn deprecated extract-text-webpack-plugin@3.0.2: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm warn deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm warn deprecated uglify-es@3.3.10: support for ECMAScript is superseded by `uglify-js` as of v3.13.0 ([WARNING] Use 3.3.9 instead of 3.3.10, reason: see https://github.com/mishoo/UglifyJS2/issues/2896)
npm warn deprecated bfj-node4@5.3.1: Switch to the `bfj` package for fixes and new features!
npm warn deprecated babel-eslint@8.2.6: babel-eslint is now @babel/eslint-parser. This package will no longer receive 
updates.
npm warn deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm warn deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm warn deprecated svgo@0.7.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm warn deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm warn deprecated vue@2.7.16: Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.
npm warn deprecated eslint@4.19.1: This version is no longer supported. Please see https://eslint.org/version-support 
for other options.
npm warn deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.

added 1908 packages in 2m

122 packages are looking for funding
  run `npm fund` for details


Running eslint --fix to comply with chosen preset rules...
# ========================


> frontend@1.0.0 lint
> eslint --ext .js,.vue src test/unit test/e2e/specs --fix

在创建项目的过程中会弹出一些与项目相关的选项需要回答,按照真实情况进行输入即可。

  1. 安装 vue 依赖模块
cd frontend
cnpm install
cnpm install  vue-resource
cnpm install element-ui
PS E:\coding\Django_learn\django_vue> cnpm install  vue-resource
√ Linked 31 latest versions fallback to E:\coding\Django_learn\django_vue\node_modules\.store\node_modules
tly_updates.txt)
  Today:
    → vue-resource@1.5.3 › got@11.8.6 › @types/cacheable-request@6.0.3 › @types/node@*(22.8.7) (12:02:53)
√ Installed 1 packages on E:\coding\Django_learn\django_vue
√ All packages installed (32 packages installed from npm registry, used 2s(network 2s), speed 387.11KB/s, json 25(139.05KB), tarball 652.98KB, manifests cache hit 6, etag hit 6 / miss 0)

dependencies:
+ vue-resource ^1.5.3

PS E:\coding\Django_learn\django_vue> cnpm install element-ui
>>
√ Linked 10 latest versions fallback to E:\coding\Django_learn\django_vue\node_modules\.store\node_modules
√ Linked 2 public hoist packages to E:\coding\Django_learn\django_vue\node_modules
peerDependencies WARNING element-ui@latest requires a peer of vue@^2.5.17 but none was installed, packageDir: E:\coding\Django_learn\django_vue\node_modules\.store\element-ui@2.15.14\node_modules\element-ui
deprecate element-ui@2.15.14async-validator@1.8.5 › babel-runtime@6.26.0 › core-js@^2.4.0 core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web 
compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
√ Run 1 script(s) in 176ms.
√ Installed 1 packages on E:\coding\Django_learn\django_vue
√ All packages installed (10 packages installed from npm registry, used 4s(network 4s), speed 603.25KB/s, json 10(174.66KB), tarball 2.37MB, manifests cache hit 0, etag hit 0 / miss 0)

dependencies:
+ element-ui ^2.15.14
  1. 现在我们可以看到整个文件目录结构是这样的:

在这里插入图片描述
6. 在frontend目录src下包含入口文件main.js,入口组件App.vue等。后缀为vue的文件是Vue.js框架定义的单文件组件,其中标签中的内容可以理解为是类html的页面结构内容。

  1. src/component文件夹下新建一个名为Home.vue的组件,通过调用之前在Django上写好的api,实现添加书籍和展示书籍信息的功能。在样式组件上我们使用了饿了么团队推出的element-ui,这是一套专门匹配Vue.js框架的功能样式组件。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2232335.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

论文翻译 | Evaluating the Robustness of Discrete Prompts

摘要 离散提示已被用于调整预训练语言模型&#xff0c;以适应不同的NLP任务。特别是&#xff0c;从一小组训练实例中生成离散提示的自动方法已经报告了优越的性能。然而&#xff0c;仔细观察习得的提示会发现&#xff0c;它们包含嘈杂和反直觉的词汇结构&#xff0c;而这些在手…

自适应对话式团队构建,提升语言模型代理的复杂任务解决能力

人工智能咨询培训老师叶梓 转载标明出处 如何有效利用多个大模型&#xff08;LLM&#xff09;代理解决复杂任务一直是一个研究热点。由美国南加州大学、宾夕法尼亚州立大学、华盛顿大学、早稻田大学和谷歌DeepMind的研究人员联合提出了一种新的解决方案——自适应团队构建&…

linux之网络子系统- TCP连接的开销,主要是内存的开销

一、相关实际问题 内核是如何管理内存的如何查看内核使用的内存信息服务器上一条ESTABLISH状态的空连接需要消耗多少内存机器上出现了3万多个TIME_WAIT&#xff0c;内存开销会不会很大 二、Linux内核如何管理内存 内核针对自己的应用场景&#xff0c;使用了一种叫做SLAB/SLU…

企业AI助理驱动的决策支持:从数据洞察到战略执行

在当今瞬息万变的商业环境中&#xff0c;企业面临着前所未有的竞争压力和不确定性。为了保持竞争力&#xff0c;企业不仅需要迅速响应市场变化&#xff0c;还需要做出基于数据的明智决策。随着人工智能技术的飞速发展&#xff0c;企业AI助理正在成为决策过程中的重要工具&#…

二、应用层,《计算机网络(自顶向下方法 第7版,James F.Kurose,Keith W.Ross)》

文章目录 零、前言一、应用层协议原理1.1 网络应用的体系结构1.1.1 客户-服务器(C/S)体系结构1.1.2 对等体&#xff08;P2P&#xff09;体系结构1.1.3 C/S 和 P2P体系结构的混合体 1.2 进程通信1.2.1 问题1&#xff1a;对进程进行编址&#xff08;addressing&#xff09;&#…

02-Dubbo特性及工作原理

02-Dubbo特性及工作原理 Dubbo 的特性 这里说一下 Dubbo 最主要的特性&#xff0c;从这些特性中&#xff0c;就可以看出来我们为什么要选用 Dubbo&#xff0c;也可以将 Dubbo 和 Spring Cloud 进行对比&#xff0c;比如我们搭建一套微服务系统&#xff0c;出于什么考虑选用 Dub…

通义灵码AI程序员你在用吗?

大家好&#xff0c;我是袁庭新。之前给大家介绍过AI编码助手——通义灵码&#xff0c;这期给大家分享通义灵码AI程序员的一些功能。 随着大模型的持续进化&#xff0c;在语义理解、代码生成、开发工作流等方面的能力也获得了持续、全面的提升。你说&#xff0c;要是有个编程小…

好难的题啊

序&#xff1a; 1.极坐标本质为变化的圆&#xff1a;动曲线---》格林公式 2.曲线积分常见的化简就是对dx&#xff0c;dy进行操作&#xff0c;这要求寻找到合适函数&#xff0c;而极坐标就是天然的函数&#xff08;参数方程&#xff09; 3.重积分--》累次积分--》单独看其中一…

大学适合学C语言还是Python?

在大学学习编程时&#xff0c;选择C语言还是Python&#xff0c;这主要取决于你的学习目标、专业需求以及个人兴趣。以下是对两种语言的详细比较&#xff0c;帮助你做出更明智的选择&#xff1a; C语言 优点&#xff1a; 底层编程&#xff1a;C语言是一种底层编程语言&#x…

开源模型应用落地-Qwen2.5-7B-Instruct与TGI实现推理加速

一、前言 目前&#xff0c;大语言模型已升级至Qwen2.5版本。无论是语言模型还是多模态模型&#xff0c;均在大规模多语言和多模态数据上进行预训练&#xff0c;并通过高质量数据进行后期微调以贴近人类偏好。在本篇学习中&#xff0c;将集成 Hugging Face的TGI框架实现模型推理…

【QT】Qt对话框

个人主页~ Qt窗口属性~ Qt窗口 五、对话框2、Qt内置对话框&#xff08;1&#xff09;Message Box&#xff08;2&#xff09;QColorDialog&#xff08;3&#xff09;QFileDialog&#xff08;4&#xff09;QFontDialog&#xff08;5&#xff09;QInputDialog 五、对话框 2、Qt内…

ubuntu交叉编译expat库给arm平台使用

1.下载expat库源码: https://github.com/libexpat/libexpat/release?page=2 wget https://github.com/libexpat/libexpat/release/download/R_2_3_0/expat-2.3.0.tar.bz2 下载成功: 2.解压expat库,并进入解压后的目录: tar xjf expat-2.3.0.tar.bz2 cd expat-2.3.0 <…

NPOI 操作详解(操作Excel)

目录 1. 安装 NPOI 2. 使用 NPOI 创建新 Excel 文件 3. 设置列宽和行高 1. 设置列宽 2. 设置行高 3. 同时设置列宽和行高 4. 设置统一的行高 5. 设置统一的列宽 6. 应用统一的行高和列宽 4. 合并单元格 5. 设置单元格样式&#xff08;字体、边框、背景色等&#xf…

【Javaee】网络原理-http协议(二)

前言 上一篇博客初步介绍了抓包工具的安装及使用&#xff0c;介绍了http请求报文与响应报文的格式。​​​​​​【Javaee】网络原理—http协议&#xff08;一&#xff09;-CSDN博客 本篇将详细介绍http的方法和http报文中请求头内部键值对的含义与作用&#xff0c;以及常见状…

大模型系列——AlphaZero/强化学习/MCTS

AlphaGo Zero无需任何人类历史棋谱&#xff0c;仅使用深度强化学习&#xff0c;从零开始训练三天的成就已远远超过了人类数千年积累的围棋知识。 1、围棋知识 &#xff08;1&#xff09;如何简单理解围棋知识 &#xff08;2&#xff09;数子法分胜负&#xff1a;https://zhu…

得物多模态大模型在重复商品识别上的应用和架构演进

重复商品治理介绍 根据得物的平台特性&#xff0c;同一个商品在平台上不能出现多个链接&#xff0c;原因是平台需要保证一品一链的特点&#xff0c;以保障商品的集中竞价&#xff0c;所以说一个商品在整个得物平台上只能有一个商详链接&#xff0c;因此我们需要对一品多链的情…

1、DevEco Studio 鸿蒙仓颉应用创建

1. 仓颉鸿蒙应用简介 因为仓颉是静态编译型语言&#xff0c;使用仓颉开发的应用执行效率更高。而且主打全场景&#xff0c;后续可并入仓颉生态&#xff0c;其和ArkTS都是基于ArkUI进行开发&#xff0c;最大的区别是typescript和仓颉语法间的差异。 2. 应用创建 前置条件&…

vue3项目中实现el-table分批渲染表格

开篇 因最近工作中遇到了无分页情景下页面因大数据量卡顿的问题&#xff0c;在分别考虑并尝试了懒加载、虚拟滚动、分批渲染等各个方法后&#xff0c;最后决定使用分批渲染来解决该问题。 代码实现 表格代码 <el-table :data"currTableData"borderstyle"wi…

LeetCode:82. 删除排序链表中的重复元素 II(重复的一个都不保留)

目录 题目描述: 代码: 第一种: 第二种: 题目描述: 给定一个已排序的链表的头 head &#xff0c; 删除原始链表中所有重复数字的节点&#xff0c;只留下不同的数字 。返回 已排序的链表 。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,3,4,4,5] 输出&#xff1a;[1,2…

偏差与方差的基本概念

在机器学习中&#xff0c;Bias-Variance Tradeoff&#xff08;偏差-方差权衡&#xff09; 是一个核心概念&#xff0c;帮助我们理解模型的误差来源以及如何调节模型复杂度以达到更好的泛化性能。在这篇博客中&#xff0c;我们将深入讨论什么是偏差和方差&#xff0c;以及如何平…