每天在网页上生成一个加密文件

Generating an encrypted file on a webpage daily

我有一个 python 程序可以读取加密文件以提取所需的设置和时间。加密文件应每分钟更新一次,并应由多个用户远程访问。

有没有办法在网页上生成加密文件(带有固定的超链接;比如 www.website-name.com/log.txt)并在特定时间范围内(例如,每分钟,hourly,每天,等等)。然后,我可以从 url.

访问该文件

有办法吗?

在服务器上安装redis并安装redis-py 参考 link 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)