Make simple ftp server more reusable and add params

This commit is contained in:
Isaac Shoebottom 2024-04-19 15:32:12 -03:00
parent 7be7397ab1
commit 93a2d7e329

View File

@ -1,16 +1,26 @@
param (
[int] [alias('p')] $port = 21,
[string] [alias('d')] $directory = '.',
[bool] [alias('w')] $write = $false
)
$venv = "\.pyftplib"
$venv = $HOME + $venv
# Create virtual environment # Create virtual environment
if (-not (Test-Path venv)) { if (-not (Test-Path $venv)) {
virtualenv venv write-host "Creating virtual environment at $venv"
virtualenv "$venv"
} }
# Activate virtual environment # Activate virtual environment
.\venv\Scripts\activate.ps1 . ($venv + "\Scripts\Activate.ps1")
# Install dependencies # Install dependencies
pip install pyftpdlib pip install pyftpdlib
# Run FTP server # Run FTP server
python -m pyftpdlib if ($write) {
python -m pyftpdlib -p $port -d $directory -w
# Not working for streaming video files } else {
# twistd -n ftp -r . python -m pyftpdlib -p $port -d $directory
}