【SH】Ubuntu Server 24搭建Web服務器訪問Python程序研發筆記

文章目錄

  • 說個問題
  • 寫個方案
  • 一、安裝Ubuntu Server
  • 二、安裝Web服務器
    • 采用Nginx服務器
  • 三、安裝Python及依賴
    • 創建項目虛擬環境
  • 四、安裝Python Web框架
    • 采用Flask框架
    • 創建和運行Flask應用(以后的重點)
  • 五、安裝WSGI服務器
    • 采用Gunicorn
  • 六、配置Nginx
  • 七、驗證部署
  • 八、擴展
    • 編寫POST請求

說個問題

自己寫了一個Python小程序,傳入一定參數就有一定的輸出,現在想開放給所有人在線使用,如何搭建服務器以及如何處理用戶的請求和響應???

寫個方案

存在多種方案,作者采用的是Gunicorn配合Nginx,用戶訪問Nginx服務器,Nginx反向代理將請求傳給Gunicorn,Gunicorn調用Python應用程序,應用程序處理后將結果回傳Gunicorn,Gunicorn傳遞給Nginx,Nginx最后響應給用戶。

Nginx
Gunicorn
Flask
動態處理
反向代理
請求響應
用戶請求
Web服務器
Python Web框架
Python 腳本

一、安裝Ubuntu Server

參考文章:【SH】VMware虛擬機安裝Ubuntu Server 24系統研發筆記

二、安裝Web服務器

采用Nginx服務器

在線文檔和支持:http://nginx.org/
也可以采用Apache,作者經過詳細了解和異同點比較之后選擇了Nginx,Nginx更加輕量級,資源消耗更少,靜態文件(如HTML、圖片、CSS等直接從磁盤讀取的內容)處理更加高效,配置更加簡單。而動態文件可以反向代理將動態請求轉發給后端的應用程序服務器處理(如uWSGI)。

  1. 更新軟件包索引,確保索引是最新的,sudo apt update
sh@sheephero:~$ sudo apt update
[sudo] password for sh:
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates InRelease [126 kB]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-backports InRelease [126 kB]
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Fetched 252 kB in 1s (189 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
66 packages can be upgraded. Run 'apt list --upgradable' to see them.
N: Missing Signed-By in the sources.list(5) entry for 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu'
N: Missing Signed-By in the sources.list(5) entry for 'http://mirrors.tuna.tsinghua.edu.cn/ubuntu'
  1. 用apt包管理器安裝Nginx,sudo apt install nginx
sh@sheephero:~$ sudo apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:nginx-common
Suggested packages:fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:nginx nginx-common
0 upgraded, 2 newly installed, 0 to remove and 66 not upgraded.
Need to get 552 kB of archives.
After this operation, 1,596 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main amd64 nginx-common all 1.24.0-2ubuntu7.1 [31.2 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main amd64 nginx amd64 1.24.0-2ubuntu7.1 [521 kB]
Fetched 552 kB in 1s (1,071 kB/s)
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 83751 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.24.0-2ubuntu7.1_all.deb ...
Unpacking nginx-common (1.24.0-2ubuntu7.1) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.24.0-2ubuntu7.1_amd64.deb ...
Unpacking nginx (1.24.0-2ubuntu7.1) ...
Setting up nginx (1.24.0-2ubuntu7.1) ...
Setting up nginx-common (1.24.0-2ubuntu7.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Processing triggers for ufw (0.36.2-6) ...
Processing triggers for man-db (2.12.0-4build2) ...
Scanning processes...
Scanning linux images...Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
  1. 啟動Nginx服務并檢查其狀態,啟動:sudo systemctl start nginx 查看狀態:sudo systemctl status nginx
sh@sheephero:~$ sudo systemctl start nginx
sh@sheephero:~$ sudo systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)Active: active (running) since Mon 2024-12-16 01:06:56 UTC; 9min agoDocs: man:nginx(8)Process: 3273 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)Process: 3275 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)Main PID: 3276 (nginx)Tasks: 3 (limit: 4556)Memory: 2.4M (peak: 2.5M)CPU: 11msCGroup: /system.slice/nginx.service├─3276 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"├─3277 "nginx: worker process"└─3279 "nginx: worker process"Dec 16 01:06:56 sheephero systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
Dec 16 01:06:56 sheephero systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
  1. 打開瀏覽器,輸入服務器的IP地址和端口(端口默認80),如果看見Nginx的歡迎界面,說明安裝成功!😀🎉

測試Nginx

三、安裝Python及依賴

Ubuntu Server 24系統自帶Python3,查看安裝版本:python3 --version

sh@sheephero:~$ python3 --version
Python 3.12.3

但是沒有安裝venv依賴,需要安裝: apt install python3.12-venv

sh@sheephero:~$ sudo apt install python3.12-venv
[sudo] password for sh:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:python3-pip-whl python3-setuptools-whl
The following NEW packages will be installed:python3-pip-whl python3-setuptools-whl python3.12-venv
0 upgraded, 3 newly installed, 0 to remove and 66 not upgraded.
Need to get 2,424 kB of archives.
After this operation, 2,771 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/universe amd64 python3-pip-whl all 24.0+dfsg-1ubuntu1.1 [1,703 kB]
Get:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/universe amd64 python3-setuptools-whl all 68.1.2-2ubuntu1.1 [716 kB]
Get:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/universe amd64 python3.12-venv amd64 3.12.3-1ubuntu0.3 [5,678 B]
Fetched 2,424 kB in 1s (3,600 kB/s)
Selecting previously unselected package python3-pip-whl.
(Reading database ... 83799 files and directories currently installed.)
Preparing to unpack .../python3-pip-whl_24.0+dfsg-1ubuntu1.1_all.deb ...
Unpacking python3-pip-whl (24.0+dfsg-1ubuntu1.1) ...
Selecting previously unselected package python3-setuptools-whl.
Preparing to unpack .../python3-setuptools-whl_68.1.2-2ubuntu1.1_all.deb ...
Unpacking python3-setuptools-whl (68.1.2-2ubuntu1.1) ...
Selecting previously unselected package python3.12-venv.
Preparing to unpack .../python3.12-venv_3.12.3-1ubuntu0.3_amd64.deb ...
Unpacking python3.12-venv (3.12.3-1ubuntu0.3) ...
Setting up python3-setuptools-whl (68.1.2-2ubuntu1.1) ...
Setting up python3-pip-whl (24.0+dfsg-1ubuntu1.1) ...
Setting up python3.12-venv (3.12.3-1ubuntu0.3) ...
Scanning processes...
Scanning linux images...Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.

安裝Python及依賴(已安裝可省略)

sudo apt install python3 python3-pip python3-venv

創建項目虛擬環境

  1. 選擇一個合適的目錄用于存放項目文件,并在該目錄中創建Python虛擬環境
mkdir dip_project && cd dip_project 

項目文件夾

  1. 為了管理項目的依賴,很有必要每個項目創建一個虛擬環境:python3 -m venv dipenv

項目虛擬環境

  1. 激活Python虛擬環境 source dipenv/bin/activate
    激活后,終端提示符會變為(dipenv),表示當前正在使用虛擬環境。source命令是Ubuntu中bash shell的一個內置命令,用于在當前shell環境中讀取并執行某個文件中的命令。退出虛擬環境:deactivate
sh@sheephero:~/dip_project$ source dipenv/bin/activate
(dipenv) sh@sheephero:~/dip_project$

四、安裝Python Web框架

采用Flask框架

參考文檔:https://pypi.org/project/Flask/
也可以采用Django框架,作者經過詳細了解和異同點比較之后選擇了Flask,Flask更加輕量級且靈活,適合初學者和開發小型應用程序,核心功能簡單,但也可以通過擴展實現強大功能。

  1. 在激活的虛擬環境中,使用pip安裝Flask,pip install flask
(dipenv) sh@sheephero:~/dip_project$ pip install Flask
Collecting FlaskDownloading flask-3.1.0-py3-none-any.whl.metadata (2.7 kB)
Collecting Werkzeug>=3.1 (from Flask)Downloading werkzeug-3.1.3-py3-none-any.whl.metadata (3.7 kB)
Collecting Jinja2>=3.1.2 (from Flask)Downloading jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)
Collecting itsdangerous>=2.2 (from Flask)Downloading itsdangerous-2.2.0-py3-none-any.whl.metadata (1.9 kB)
Collecting click>=8.1.3 (from Flask)Downloading click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting blinker>=1.9 (from Flask)Downloading blinker-1.9.0-py3-none-any.whl.metadata (1.6 kB)
Collecting MarkupSafe>=2.0 (from Jinja2>=3.1.2->Flask)Downloading MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.0 kB)
Downloading flask-3.1.0-py3-none-any.whl (102 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.0/103.0 kB 352.3 kB/s eta 0:00:00
Downloading blinker-1.9.0-py3-none-any.whl (8.5 kB)
Downloading click-8.1.7-py3-none-any.whl (97 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 1.6 MB/s eta 0:00:00
Downloading itsdangerous-2.2.0-py3-none-any.whl (16 kB)
Downloading jinja2-3.1.4-py3-none-any.whl (133 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.3/133.3 kB 2.1 MB/s eta 0:00:00
Downloading werkzeug-3.1.3-py3-none-any.whl (224 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.5/224.5 kB 2.8 MB/s eta 0:00:00
Downloading MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23 kB)
Installing collected packages: MarkupSafe, itsdangerous, click, blinker, Werkzeug, Jinja2, Flask
Successfully installed Flask-3.1.0 Jinja2-3.1.4 MarkupSafe-3.0.2 Werkzeug-3.1.3 blinker-1.9.0 click-8.1.7 itsdangerous-2.2.0
(dipenv) sh@sheephero:~/dip_project$
  1. 驗證安裝:python -m flask --version 如果安裝成功,會顯示Flask的版本信息
(dipenv) sh@sheephero:~/dip_project$ python -m flask --version
Python 3.12.3
Flask 3.1.0
Werkzeug 3.1.3

創建和運行Flask應用(以后的重點)

  1. 創建和運行Flask應用,在項目目錄里面新建一個【app.py】文件vim app.py,寫入如下內容(IP地址就是Ubuntu的地址):
# save this as app.py
from flask import Flaskapp = Flask(__name__)@app.route("/")
def hello():return "Hello, World!"if __name__ == '__main__':app.run(host='172.16.37.37', port=5000)

保存后,運行如下命令:python app.py,使之處于監聽狀態。

(dipenv) sh@sheephero:~/dip_project$ python app.py* Serving Flask app 'app'* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.* Running on http://172.16.37.37:5000
Press CTRL+C to quit

運行情況
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.警告:這是一個開發服務器。不要用于生產環境。請使用生產WSGI服務器代替。

  1. 打開客戶機的瀏覽器,訪問虛擬機的服務器,在瀏覽器中輸入http://172.16.37.37:5000來查看Flask應用的輸出

應用輸出

五、安裝WSGI服務器

WSGI服務器,用于Web服務器反向代理Python程序。
uWSGI和Gunicorn都是Web服務器,實現了WSGI(Web Server Gateway Interface)協議,用于接收請求并分發給后端應用(如Django或Flask)。

采用Gunicorn

也可以安裝uWSGI,作者經過詳細了解和異同點比較之后選擇了Gunicorn,Gunicorn配置相對簡單,易于上手。它遵循“Keep it simple and stupid”(KISS)的設計理念,提供了一個穩定且易于維護的Web服務器環境。

  1. 在項目虛擬環境中安裝gunicorn,
(dipenv) sh@sheephero:~/dip_project$ pip install gunicorn
Collecting gunicornDownloading gunicorn-23.0.0-py3-none-any.whl.metadata (4.4 kB)
Collecting packaging (from gunicorn)Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
Downloading gunicorn-23.0.0-py3-none-any.whl (85 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 85.0/85.0 kB 305.7 kB/s eta 0:00:00
Downloading packaging-24.2-py3-none-any.whl (65 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.5/65.5 kB 1.2 MB/s eta 0:00:00
Installing collected packages: packaging, gunicorn
Successfully installed gunicorn-23.0.0 packaging-24.2
  1. 重新使用Gunicorn運行Flask應用(假設Flask應用名為app.py,且應用實例名為app),根據上文編寫的app.py文件來輸入命令gunicorn --workers 4 --bind 0.0.0.0:6758 app:app,這條命令會啟動Gunicorn,并監聽所有網絡接口上的6758端口。
    【–workers 4】這個選項指定了Gunicorn應該啟動的工作進程數量。在這個例子中,它被設置為4。工作進程是實際處理請求的Python進程。增加工作進程的數量可以提高你的應用處理并發請求的能力,但是也會增加內存和CPU的使用。
    【–bind 0.0.0.0:6758】這個選項告訴Gunicorn監聽哪個IP地址和端口上的連接。0.0.0.0是一個特殊的IP地址,表示監聽所有可用的網絡接口。這意味著,如果你的服務器有多個IP地址(例如,一個內網地址和一個外網地址),你的應用將能夠在所有這些地址上接受連接。6758是端口號,是應用將監聽以接受連接的TCP端口。
    【app:app】這部分指定了要運行的WSGI應用。它通常遵循模塊名:應用對象名的格式。在這個例子中,app是Python模塊的名字,而第二個app是該模塊中定義的WSGI應用對象的名字。這意味著你的應用應該有一個名為app.py的文件,里面有一個名為app的Flask(或其他WSGI兼容框架)應用實例。
(dipenv) sh@sheephero:~/dip_project$ gunicorn --workers 4 --bind 0.0.0.0:6758 app:app
[2024-12-16 13:28:27 +0000] [25695] [INFO] Starting gunicorn 23.0.0
[2024-12-16 13:28:27 +0000] [25695] [INFO] Listening at: http://0.0.0.0:8000 (25695)
[2024-12-16 13:28:27 +0000] [25695] [INFO] Using worker: sync
[2024-12-16 13:28:27 +0000] [25696] [INFO] Booting worker with pid: 25696
[2024-12-16 13:28:27 +0000] [25697] [INFO] Booting worker with pid: 25697
[2024-12-16 13:28:27 +0000] [25698] [INFO] Booting worker with pid: 25698
[2024-12-16 13:28:28 +0000] [25699] [INFO] Booting worker with pid: 25699

六、配置Nginx

配置Nginx以轉發請求給Gunicorn

  1. 備份Nginx的默認配置文件:
(dipenv) sh@sheephero:/etc/nginx/sites-available$ sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak
(dipenv) sh@sheephero:/etc/nginx/sites-available$ tree -L 3
.
├── default
└── default.bak
1 directory, 2 files
  1. 編輯Nginx的配置文件:
sudo vim /etc/nginx/sites-available/default
  1. 在配置文件中添加或修改以下內容,以將請求轉發給Gunicorn,your_server_ip_or_domain替換為你的服務器IP地址或域名:
server {listen 80;server_name your_server_ip_or_domain;location / {proxy_pass http://127.0.0.1:6758;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}
}
  1. 測試Nginx配置文件的正確性:
sudo nginx -t
(dipenv) sh@sheephero:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
  1. 重啟Nginx服務以應用更改:
sudo systemctl restart nginx

七、驗證部署

啟動Gunicorn保持監聽,啟動Nginx服務,然后通過瀏覽器輸入http://172.16.37.37 訪問服務:

驗證部署

八、擴展

編寫POST請求

請看下一篇文章:【SH】Ubuntu Server 24搭建Web服務器訪問Python程序研發筆記

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/63400.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/63400.shtml
英文地址,請注明出處:http://en.pswp.cn/web/63400.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Vue3 重置ref或者reactive屬性值

需要重新定義一個對象綁定復制給原對象 。 實例代碼: const data () > ({groupId: ,groupCode: ,groupName: ,groupType: ,});const formData ref(data());//重置對象值 const reset()>{Object.assign(formData, data()…

C#速成(GID+圖形編程)

常用類 類說明Brush填充圖形形狀,畫刷GraphicsGDI繪圖畫面,無法繼承Pen定義繪制的對象直線等(顏色,粗細)Font定義文本格式(字體,字號) 常用結構 結構說明Color顏色Point在平面中定義點Rectan…

vue iframe進行父子頁面通信并切換URL

使用通義千問提問后得到一個很好的示例。 需求是2個項目需要使用同一個面包屑進行跳轉&#xff0c;其中一個是iframe所在的項目&#xff0c;另一個需要通過地址訪問。通過 window.parent.postMessage &#xff0c;幫助 <iframe> 內嵌入的子頁面和其父頁面之間進行跨域通…

誰說C比C++快?

看到這個問題&#xff0c;我我得說&#xff1a;這事兒沒有那么簡單。 1. 先把最大的誤區打破 "C永遠比C快" —— 某位1990年代的程序員 這種說法就像"自行車永遠比汽車省油"一樣荒謬。我們來看個例子&#xff1a; // C風格 char* str (char*)malloc(100…

【ADS射頻電路學習筆記】1. ADS基本操作

下面介紹ADS中主要仿真器的使用 1. 直流仿真 直流仿真器在控制面板的simulator-dc 直流仿真器 但是ADS自帶有很多仿真器&#xff0c;可以直接來調用 選用晶體管電流掃描的模板 就可以輸出模板 然后調入晶體管模型 然后要設置掃描的電壓&#xff0c;選擇dc仿真器對vds進行掃描…

CSS學習記錄12

CSS浮動 CSSfloat屬性規定元素如何浮動 CSSclear屬性規定哪些元素可以在清除的元素旁邊以及在哪一側浮動。 float屬性 float屬性用于定位和格式化內容&#xff0c;例如讓圖像向左浮動到容器的文本那里。 float屬性可以設置以下值之一&#xff1a; left - 元素浮動到其容器…

Chinese-Clip實現以文搜圖和以圖搜圖(transformers版)

本文不生產技術&#xff0c;只做技術的搬運工&#xff01; 前言 作者昨天使用cn_clip庫實現了一版&#xff0c;但是覺得大家復現配置環境可能有點復雜&#xff0c;因此有使用transformers庫實現了一版&#xff0c;提供大家選擇&#xff0c;第一篇參考鏈接如下&#xff1a; Ch…

【Unity3D】無限循環列表(擴展版)

基礎版&#xff1a;【Unity技術分享】UGUI之ScrollRect優化_ugui scrollrect 優化-CSDN博客 using UnityEngine; using UnityEngine.UI; using System.Collections.Generic;public delegate void OnBaseLoopListItemCallback(GameObject cell, int index); public class BaseLo…

MSSQL AlwaysOn 可用性組(Availability Group)中的所有副本均不健康排查步驟和解決方法

當遇到 MSSQL AlwaysOn 可用性組(Availability Group)中的所有副本均不健康的情況時(MSSQL AG 副本名稱: All replicas unhealthy),這通常意味著可用性組無法正常工作,數據同步和故障轉移功能可能受到影響。以下是一些可能的原因及相應的排查步驟和解決方法: 1. 檢查副本…

springboot檢測配置是否存在,如果存在則返回,不存在則提示新增

我這里是以七牛為例子 在yml中添加七牛的相關配置 qiniu: #七牛的相關配置accessKey: your_access_keysecretKey: your_secret_keybucket: your_bucket_namedomain: your_domain 對應在給配置文件來一個相應的實體類QiniuConfig Component ConfigurationProperties(prefix &…

[NOIP2016 普及組] 海港 -STL-隊列queue

[NOIP2016 普及組] 海港 題目背景 NOIP2016 普及組 T3 題目描述 小 K 是一個海港的海關工作人員&#xff0c;每天都有許多船只到達海港&#xff0c;船上通常有很多來自不同國家的乘客。 小 K 對這些到達海港的船只非常感興趣&#xff0c;他按照時間記錄下了到達海港的每一…

【Vulkan入門】16-IndexBuffer

TOC 先叨叨 上篇介紹了如何使用VertexBuffer傳入頂點信息。兩個多星期了我們一直在玩三個點&#xff0c;本篇介紹如何渲染更多的點。 在渲染前考慮一個問題&#xff0c;渲染一個三角形需要三個點&#xff0c;渲染兩個相接的三角形需要幾個點&#xff1f; 答案是6個點&#xf…

IDEA 打包普通JAVA項目為jar包

需求&#xff1a;普通java項目&#xff08;有添加依賴的jar包&#xff09;&#xff0c;沒有用maven管理依賴和打包&#xff0c;要打成jar包&#xff0c;包可以用“java -jar 包名” 啟動程序。 講如何打包前&#xff0c;先記錄下普通項目的目錄結構和怎么添加依賴包 1.目錄結…

python的流程控制語句之制作空氣質量評估系統

&#x1f468;?&#x1f4bb;個人主頁&#xff1a;開發者-曼億點 &#x1f468;?&#x1f4bb; hallo 歡迎 點贊&#x1f44d; 收藏? 留言&#x1f4dd; 加關注?! &#x1f468;?&#x1f4bb; 本文由 曼億點 原創 &#x1f468;?&#x1f4bb; 收錄于專欄&#xff1a…

Docker Compose 多應用部署 一鍵部署

介紹 Docker Compose通過一個單獨的docker-compose.yml模板文件(YAML格式)來定義一組相關聯的應用容器&#xff0c;幫助我們實現多個相互關聯的Docker容器的快速部署。 如&#xff1a;springbootmysqlnginx 如果一個個去部署他會非常的麻煩&#xff0c;這時候可以選擇Docker …

【數據結構——線性表】單鏈表的基本運算(頭歌實踐教學平臺習題)【合集】

目錄&#x1f60b; 任務描述 相關知識 測試說明 我的通關代碼: 測試結果&#xff1a; 任務描述 本關任務&#xff1a;編寫一個程序實現單鏈表的基本運算。 相關知識 為了完成本關任務&#xff0c;你需要掌握&#xff1a;初始化線性表、銷毀線性表、判定是否為空表、求線性…

git branch -r(--remotes )顯示你本地倉庫知道的所有 遠程分支 的列表

好的&#xff0c;git branch -r 這個命令用于列出遠程分支。讓我詳細解釋一下&#xff1a; 命令&#xff1a; git branch -rdgqdgqdeMac-mini ProductAuthentication % git branch -rorigin/main作用&#xff1a; 這個命令會顯示你本地倉庫知道的所有 遠程分支 的列表。它不…

【AI熱點】小型語言模型(SLM)的崛起:如何在AI時代中找到你的“左膀右臂”?

人工智能模型的演變 多年來&#xff0c;谷歌等科技巨頭和OpenAI等初創公司&#xff0c;一直在不遺余力地利用海量在線數據&#xff0c;打造更大、更昂貴的人工智能&#xff08;AI&#xff09;模型。這些大型語言模型&#xff08;LLM&#xff09;被廣泛應用于ChatGPT等聊天機器…

【昇騰】NPU ID:物理ID、邏輯ID、芯片映射關系

起因&#xff1a; https://www.hiascend.com/document/detail/zh/Atlas%20200I%20A2/23.0.0/re/npu/npusmi_013.html npu-smi info -l查詢所有NPU設備&#xff1a; [naienotebook-npu-bd130045-55bbffd786-lr6t8 DCNN]$ npu-smi info -lTotal Count : 1NPU…

Elasticsearch-DSL高級查詢操作

一、禁用元數據和過濾數據 1、禁用元數據_source GET product/_search {"_source": false, "query": {"match_all": {}} }查詢結果不顯示元數據 禁用之前: {"took" : 0,"timed_out" : false,"_shards" : {&quo…