dn42-info/deploy.py

28 lines
713 B
Python
Raw Normal View History

2024-05-12 16:45:33 +02:00
from ftplib import FTP
import requests
from os import listdir, getenv, chdir
2024-05-12 16:45:33 +02:00
from io import BytesIO
# init ftp
ftp = FTP(getenv('FTP_SERVER'))
ftp.login(getenv('FTP_USER'), getenv('FTP_PASSWORD'))
2024-10-11 11:19:34 +02:00
for f in [i for i in listdir('dist') if i.endswith('.html')]:
content = open(f, 'r').read()
ftp.storbinary('STOR ' + f, BytesIO(content.encode()))
2024-10-11 11:19:34 +02:00
ftp.storbinary('STOR geofeed.csv', BytesIO(open('geofeed.csv', 'r').read().encode()))
2024-05-12 16:45:33 +02:00
# refresh cache
2024-10-11 11:19:34 +02:00
url = 'https://api.bunny.net/purge?url=https%3A%2F%2Fdn42.m724.eu&async=false' # replace with your URL
2024-05-12 16:45:33 +02:00
headers = {
'AccessKey': getenv("ACCESS_KEY")
}
response = requests.get(url, headers=headers)
# Quit ftp
ftp.quit()