我有一个python程序,可以读取加密文件来提取所需的设置和时间。加密文件应该每分钟更新一次,并且应该由多个用户远程访问。
有没有办法在网页上生成加密文件(具有固定的超链接;例如www.website-name.com/log.txt),并在特定的时间帧(例如,每分钟、每小时、每天等)替换较旧的文件。然后,我可以从该文件的url访问该文件。
有没有办法做到这一点?
发布于 2021-04-21 19:05:57
在服务器上安装redis并安装redis-py引用链接https://github.com/andymccurdy/redis-py
$ pip install redis然后将这个添加到程序中
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
file_name = ''
# 60 can change to any time you want
expire_time = 60
encrypted_file_content = r.get('file_content')
if not encrypted_file_content:
encrypted_file_content = do_something()
r.set('file_content',encrypted_file_content,expire_time)
with open(file_name,'w') as f:
f.write(encrypted_file_content)https://stackoverflow.com/questions/67193500
复制相似问题