简体   繁体   English

使用Python FTP服务器(pyftplib)-登录时创建HTML文件

[英]Using Python FTP Server (pyftplib) - create HTML file on log in

I have a FTP server working great using Python and the pyftplib library ( https://code.google.com/p/pyftpdlib/ ). 我有一个使用Python和pyftplib库( https://code.google.com/p/pyftpdlib/ )的FTP服务器,可以很好地工作。 I would like to, on login (either anonymous or user), create a html file reflecting the latest state of the server in a nice looking way. 我想在登录时(匿名或用户登录)创建一个HTML文件,以一种美观的方式反映服务器的最新状态。 For example, all the files that are on the server and their properties nicely separated and looking nice. 例如,服务器上的所有文件及其属性都很好地分离开了,看上去也不错。 I thought that since I was already doing everything in Python, and my html wouldn't be overly complex, I would just have python write the html file on log in, and then the user could open the html file for the information that was written seconds before. 我以为,因为我已经用Python完成了所有工作,并且我的html不会太复杂,所以我只能让python在登录时编写html文件,然后用户才能打开html文件以获取所写的信息秒之前。

My main problem is that when I override the "public callbacks" section of the handlers.py (or any section so far), no file is created that I can find. 我的主要问题是,当我覆盖handlers.py的“公共回调”部分(或到目前为止的任何部分)时,没有创建任何我可以找到的文件。 I am new to python, but it seems like a modification in the handlers.py file should affect the Handler class. 我是python的新手,但似乎在handlers.py文件中进行的修改应会影响Handler类。 Another idea I plan on trying is to override the handler base class with my "on_login" function that does create the html file. 我计划尝试的另一个想法是使用确实创建html文件的“ on_login”函数覆盖处理程序基类。

What I am really asking for is 1) Advice from anybody who has done/tried this before 2) Any red flags that are going off in your head regarding my plan 3) Any other ideas (ideally strictly using python) 我真正要问的是1)任何曾经做过/尝试过此操作的人的建议2)关于我的计划的任何危险信号都在您脑海中浮现3)任何其他想法(最好严格使用python)

Thanks! 谢谢!

What worked for me was not editing the handler.py file, but rather creating my own subclass (myFTPHandler) and then redefining the onconnect method to write my html file then. 对我有用的方法不是编辑handler.py文件,而是创建自己的子类(myFTPHandler),然后重新定义onconnect方法以编写我的html文件。

Thanks for the help though! 谢谢您的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM