当前位置: 首页 > news >正文

Python 一行命令部署http、ftp服务

Python 一行命令部署http服务

文章目录

      • Python 一行命令部署http服务
      • 具体操作命令如下
      • 浏览器返回下载
      • Python 一行命令部署FTP服务

具体操作命令如下

  • 这个比nginx相对来说更加简单,可以用于部署特殊场景时如银行等部署时,各种权限控制,内网之间可以分发部署包。

  • 首先进入需要访问下载对应目录

root@raspberrypi:~ $ cd tmpfile
  • 如果Python版本为2.x,输入命令
python -m SimpleHTTPServer 80
  • 如果Python版本为3.x,输入命令
python -m http.server 80

浏览器返回下载

  • 浏览器下载

  • wget下载
pi@raspberrypi:~ $ wget 10.130.77.55/ZabbixSendApi.tar.gz
--2023-06-25 14:47:15--  http://10.130.77.55/ZabbixSendApi.tar.gz
Connecting to 10.130.77.55:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6018461 (5.7M) [application/gzip]
Saving to: ‘ZabbixSendApi.tar.gz’
ZabbixSendApi.tar.gz                                               
100%[============================================================================================================================>] 5.74M  16.4MB/s    in 0.4s    
2023-06-25 14:47:15 (16.4 MB/s) - ‘ZabbixSendApi.tar.gz’ saved [6018461/6018461]

Python 一行命令部署FTP服务

  • 快速部署FTP 服务器来临时实现文件上传下载时,利用 PythonPyftpdlib 模块可以快速的实现一个 FTP 服务器的功能。

  • pyftpdlib安装

[root@api1 ~]# pip install pyftpdlib
  • pyftpdlib 帮助信息
[root@api1 site-packages]# python -m pyftpdlib --help
Usage: python3 -m pyftpdlib [options]Start a stand alone anonymous FTP server.Options:-h, --helpshow this help message and exit-i ADDRESS, --interface=ADDRESSspecify the interface to run on (default all interfaces)-p PORT, --port=PORTspecify port number to run on (default 2121)-w, --writegrants write access for logged in user (default read-only)-d FOLDER, --directory=FOLDERspecify the directory to share (default current directory)-n ADDRESS, --nat-address=ADDRESSthe NAT address to use for passive connections-r FROM-TO, --range=FROM-TOthe range of TCP ports to use for passive connections (e.g. -r 8000-9000)-D, --debugenable DEBUG logging level-v, --versionprint pyftpdlib version and exit-V, --verboseactivate a more verbose logging-u USERNAME, --username=USERNAMEspecify username to login with (anonymous login will be disabled and password required if supplied)-P PASSWORD, --password=PASSWORDspecify a password to login with (username required to be useful)
  • ftp案例
    • 使用10001端口,指定/tmp为存储目录,使用用户名admin,密码Python@123
[root@api1 python  -m pyftpdlib -p 10001 -w -d /tmp/ -u admin -P Python@123
  • 客户端登录验证
[root@api1 ~]# ftp 10.130.41.10 10001
Connected to 10.130.41.10 (10.130.41.10).
220 pyftpdlib 1.5.9 ready.
Name (10.130.41.10:root): admin
331 Username ok, send password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls 
227 Entering passive mode (10,130,41,10,167,170).
125 Data connection already open. Transfer starting.
drwxrwxrwt   2 root     root         4096 Sep 17  2021 .ICE-unix
drwxrwxrwt   2 root     root         4096 Sep 17  2021 .Test-unix
drwxrwxrwt   2 root     root         4096 Sep 17  2021 .X11-unix
drwxrwxrwt   2 root     root         4096 Sep 17  2021 .XIM-unix
drwxrwxrwt   2 root     root         4096 Sep 17  2021 .font-unix
-rw-r--r--   1 root     root      2508216 Jan 16 09:14 11.txt
-rw-r--r--   1 root     root     13205746 Jan 16 09:13 1629.pcap
drwxr-xr-x   2 agent    agent        4096 Jan 03 05:40 hsperfdata_agent
drwxr-xr-x   2 portal   portal       4096 Jan 16 08:58 hsperfdata_portal
drwx------   3 root     root         4096 Jan 03 05:34 systemd-private-8fca0ca0813b472a8292a045e324735f-chronyd.service-h16uCI
226 Transfer complete.
ftp> put 11.txt  
local: 11.txt remote: 11.txt
227 Entering passive mode (10,130,41,10,157,167).
125 Data connection already open. Transfer starting.
226 Transfer complete.
2508216 bytes sent in 0.00447 secs (560495.23 Kbytes/sec)ftp> get  11.txt  
local: 11.txt remote: 11.txt
227 Entering passive mode (10,130,41,10,184,184).
125 Data connection already open. Transfer starting.
226 Transfer complete.
2508216 bytes received in 0.0201 secs (124520.48 Kbytes/sec)
ftp> 

本文由mdnice多平台发布

http://www.lryc.cn/news/283552.html

相关文章:

  • DBA技术栈(三):MySQL 性能影响因素
  • SpringCloud GateWay 在全局过滤器中注入OpenFeign网关后无法启动
  • web前端项目-贪吃蛇小游戏【附源码】
  • ICCV2023 | PTUnifier+:通过Soft Prompts(软提示)统一医学视觉语言预训练
  • 代码随想录 Leetcode459. 重复的子字符串(KMP算法)
  • Rust之构建命令行程序(三):重构改进模块化和错误处理
  • 广和通AI解决方案“智”赋室外机器人迈向新天地!
  • C++I/O流——(4)格式化输入/输出(第二节)
  • 九、K8S-label和label Selector
  • 【.NET Core】 多线程之(Thread)详解
  • 苹果笔记本 macbook 在 office word 中使用 mathtype 的方法
  • 课表排课小程序怎么制作?多少钱?
  • C语言总结十三:程序环境和预处理详细总结
  • tinyxml2
  • What is `@Controller` does?
  • 新版AndroidStudio dependencyResolutionManagement出错
  • 第三天业务题
  • nestjs 装饰器
  • 一款开源且不限制大小可以设置过期时间的支持分享的的开源文件共享系统picoshare 部署教程
  • eBPF运行时安全
  • Linux 系统中常见的命令,它们用于执行各种任务,包括文件和目录管理、系统信息查看、用户管理等
  • AutoEventWireup详解
  • SAP ABAP 自定义流水号 编号范围
  • 安卓、ios系统详解
  • 含并行连结的网络(GoogLeNet)
  • 计算机网络(第六版)复习提纲3
  • 怿星科技测试实验室获CNAS实验室认可,汽车以太网检测能力达国际标准
  • GORM 介绍及快速入门
  • Scrcpy:掌握你的Android设备
  • [9, 8, 7, 6][1,2] = ?