Skip to content

Instantly share code, notes, and snippets.

@mightbxg
Created September 6, 2021 09:11
Show Gist options
  • Save mightbxg/93a1fb2efcf5c6636d838d095dbc6e9e to your computer and use it in GitHub Desktop.
Save mightbxg/93a1fb2efcf5c6636d838d095dbc6e9e to your computer and use it in GitHub Desktop.
simple ftp server
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# @file ftp.py
# @brief ftp.py
# @version V1.0
# @author Nick.Liao
# @date 2017-10-18
#
# Copyright (C) 2017 Nick.Liao <simplelife_nick@hotmail.com>
# Distributed under terms of the MIT license.
"""
ftp server
"""
import sys
import os
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
if __name__ == "__main__":
path = os.path.expanduser('~')
port = 3333
if len(sys.argv) >= 2:
path = sys.argv[1]
if len(sys.argv) >=3:
port = int(sys.argv[2])
authorizer = DummyAuthorizer()
authorizer.add_anonymous(path, perm='elradfmwM')
authorizer.add_user("a","abc",path, perm='elradfmwM')
handler = FTPHandler
handler.authorizer = authorizer
server = FTPServer(("", port), handler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment