如何用Python单行代码搭建简易文件共享服务器?

2026-05-21 17:261阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计254个文字,预计阅读时间需要2分钟。

如何用Python单行代码搭建简易文件共享服务器?

目录

1.使用前提示

2.使用命令

3.参数详解

1. 使用前提示

需要提前安装好Python环境才能使用。

2. 使用命令python -m http.server 9999

3. 参数详解- python:调用Python解释器- -m:指定运行模块- http.server:运行HTTP服务器模块- 9999:指定端口号,默认为8000,可自定义


目录

​​1、使用前提​​

​​2、使用命令​​

如何用Python单行代码搭建简易文件共享服务器?

​​3、参数详解​​


1、使用前提

需要提前安装好python环境才可以使用哦

2、使用命令

python -m http.server 9999

3、参数详解

python -m http.server -husage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port]

positional arguments:
port Specify alternate port [default: 8000]

optional arguments:
-h, --help show this help message and exit
--cgi Run as CGI Server
--bind ADDRESS, -b ADDRESS
Specify alternate bind address [default: all
interfaces]
--directory DIRECTORY, -d DIRECTORY
Specify alternative directory [default:current
directory]

本文共计254个文字,预计阅读时间需要2分钟。

如何用Python单行代码搭建简易文件共享服务器?

目录

1.使用前提示

2.使用命令

3.参数详解

1. 使用前提示

需要提前安装好Python环境才能使用。

2. 使用命令python -m http.server 9999

3. 参数详解- python:调用Python解释器- -m:指定运行模块- http.server:运行HTTP服务器模块- 9999:指定端口号,默认为8000,可自定义


目录

​​1、使用前提​​

​​2、使用命令​​

如何用Python单行代码搭建简易文件共享服务器?

​​3、参数详解​​


1、使用前提

需要提前安装好python环境才可以使用哦

2、使用命令

python -m http.server 9999

3、参数详解

python -m http.server -husage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port]

positional arguments:
port Specify alternate port [default: 8000]

optional arguments:
-h, --help show this help message and exit
--cgi Run as CGI Server
--bind ADDRESS, -b ADDRESS
Specify alternate bind address [default: all
interfaces]
--directory DIRECTORY, -d DIRECTORY
Specify alternative directory [default:current
directory]