相关疑难解决方法(0)

python中的一行ftp服务器

是否可以在python中使用一行命令来执行简单的ftp服务器?我希望能够以快速和临时的方式将文件传输到Linux机器而无需安装ftp服务器.最好是使用内置python库的方式,这样就没有什么额外的安装了.

python ftp ftp-server

93
推荐指数
6
解决办法
11万
查看次数

你是如何通过Python(而不是通过Twisted)运行Twisted应用程序的?

我正在通过学​​习Twisted工作,偶然发现了一些我不太确定我非常喜欢的东西 - "Twisted Command Prompt".我正在摆弄我的Windows机器上的Twisted,并尝试运行"聊天"示例:

from twisted.protocols import basic

class MyChat(basic.LineReceiver):
    def connectionMade(self):
        print "Got new client!"
        self.factory.clients.append(self)

    def connectionLost(self, reason):
        print "Lost a client!"
        self.factory.clients.remove(self)

    def lineReceived(self, line):
        print "received", repr(line)
        for c in self.factory.clients:
            c.message(line)

    def message(self, message):
        self.transport.write(message + '\n')


from twisted.internet import protocol
from twisted.application import service, internet

factory = protocol.ServerFactory()
factory.protocol = MyChat
factory.clients = []

application = service.Application("chatserver")
internet.TCPServer(1025, factory).setServiceParent(application)
Run Code Online (Sandbox Code Playgroud)

但是,要将此应用程序作为Twisted服务器运行,我必须通过"Twisted命令提示符"运行它,并使用以下命令:

twistd -y chatserver.py
Run Code Online (Sandbox Code Playgroud)

有没有办法更改代码(设置Twisted配置设置等),以便我可以通过以下方式运行它:

python chatserver.py
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索,但搜索条件似乎太模糊,无法返回任何有意义的回复.

谢谢.

python sockets networking twisted

19
推荐指数
2
解决办法
9436
查看次数

标签 统计

python ×2

ftp ×1

ftp-server ×1

networking ×1

sockets ×1

twisted ×1