惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
M
MIT News - Artificial intelligence
MyScale Blog
MyScale Blog
博客园_首页
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
Vercel News
Vercel News
小众软件
小众软件
博客园 - 司徒正美
雷峰网
雷峰网
T
Tailwind CSS Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
罗磊的独立博客
量子位
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog

月与灯依旧

回国见闻 – 月与灯依旧 Set up self-hosted runners for Github Actions – 月与灯依旧 Javascript Array – 月与灯依旧 Get Ubuntu release code name in Script – 月与灯依旧 大学回忆录之2023 – 月与灯依旧 found a tab character that violates indentation – 月与灯依旧 那些年,我所呆过的互联网公司 – 月与灯依旧 pproxy简单介绍 – 月与灯依旧 How to add or remove a directory from media library on Windows – 月与灯依旧
The easiest way to build a http/ftp server with Python – ...
by bear · 2022-12-02 · via 月与灯依旧

Build a HTTP Server

# Python2
python -m SimpleHTTPServer PORT

# Python 3
python -m http.server PORT
python -m http.server PORT --bind example.com

Build a FTP Server

pip install pyftpdlib

python -m pyftpdlib -p 21    # notice: it's ftpd, not ftp

# if you want a username and password
python -m pyftpdlib -u USERNAME -P PASSWORD

A powershell script could run in Windows

place a file named “ftp.ps1” with the following content:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-Location -Path D:\Download
Start-Process -NoNewWindow python --version
python -m pyftpdlib -p 21 -u USERNAME -P PASSWORD
Read-Host -Prompt "Press Enter to exit"

and then run with Powershell

Advanced Usage

from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from pyftpdlib.authorizers import DummyAuthorizer


authorizer = DummyAuthorizer()
authorizer.add_user('python', '123456', 'F:\\Working~Study', perm='elradfmwM')
handler = FTPHandler
handler.authorizer = authorizer


server = FTPServer(('0.0.0.0', 8888), handler)
server.serve_forever()

Reference
https://blog.51cto.com/phyger/5182139