Python 簡單快速搭建HTTP服務

2021-10-01 22:18:23 字數 1500 閱讀 2225

在python中,可以使用某些模組來搭建乙個非常簡單基本的web伺服器來訪問當前目錄的檔案。

.py 檔案

建立.py檔案,將以下**寫入其中,在指定資料夾中,執行.py檔案

# 埠號

)command

python -m ******httpserver 8000
# 可後台執行 ctrl + c 埠不會關閉

# 關閉當前視窗 埠不會關閉

.py 檔案

建立.py檔案,將以下**寫入其中,在指定資料夾中,執行.py檔案

)command

python -m http.server 8000
# 預設情況下,伺服器將自身繫結到所有介面。 -b/--bind 指定繫結到的特定位址。

# 預設情況下,伺服器使用當前目錄。-d/--directory指定應用向其提供檔案的目錄。

Centos7 Python簡易搭建http伺服器

一 背景 二 步驟 1.使用python httpserver httpserver是python 2自帶的乙個模組,是python的web伺服器。它在python 3已經合併到http.server模組中。httpserver在python 3的用法與在python 2的用法相似 python3 ...

Linux下certpot 免費搭建https協議

centos配置let s encrypt並自動更新 假如就放在 home下 如果報錯,再執行一遍 email為郵箱,w後面為 目錄,d後面為 網域名稱 然後生成的證書在 etc letsencrypt live 下 編輯nginx配置檔案,不同框架,需要改不同的東西,大同小異 server loc...

Python 使用request傳送http請求

requests.get headers response requests.post login headers headers,data data response requests.post login allow redirects false 注 若不禁止重定向,則當響應是302時,req...