Python3 use a two-way transport file by WEB,Solved//in


Introduce

之前在虚拟机、远程的服务器,如果因为一些硬性限制,但又想传输的文件的时候,没有太好的办法的时候,系统如果默认安装了Python3,可以使用python自带的server服务来进行文件传输,

// python 2.X 
temp$ python -m SimpleHTTPServer 2020

// python 3.X 
temp$ python -m http.server 3030

但是,有个缺点,就是他只能单向传输,就是你只能从服务器上拉取文件回来,不能传输文件到服务器,基于这个需求,有了下文的解决方案。

Solved

// install , 如果不能上网,可以先将代码下载到本地,然后在传输到目标系统
git clone https://github.com/freelamb/simple_http_server.git


// 进入你要共享的文件夹
PS D:\home\code\python\simpy-server> cd .\file\
PS D:\home\code\python\simpy-server\file> ls

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        2023/3/20     14:36              0 1.txt
-a----        2023/3/20     14:37              0 a.txt
-a----        2023/3/20     14:37              0 test.txt

// run
PS D:\home\code\python\simpy-server\file> python ..\simple_http_server\simple_http_server.py 8989
server_version: simple_http_server/0.3.1, python_version: Python/3.10.2
sys encoding: utf-8
Serving http on: 0.0.0.0, port: 8989 ... (http://0.0.0.0:8989/)

Use the effect demo:

Reference

linux下几种文件传输的方式介绍
https://www.cnblogs.com/mysticbinary/p/12785763.html

使用python构建简单的http上传下载服务
https://www.jianshu.com/p/2147b7e7cf38

Source code
https://github.com/freelamb/simple_http_server

一个软件开发者(安全方向)的公众号。 Mysticbinary

Github:https://github.com/Mysticbinary
君何不畅谈一番?

相关内容

    暂无相关文章

评论关闭