28 lines
No EOL
713 B
Python
28 lines
No EOL
713 B
Python
from ftplib import FTP
|
|
import requests
|
|
from os import listdir, getenv, chdir
|
|
from io import BytesIO
|
|
|
|
# init ftp
|
|
|
|
ftp = FTP(getenv('FTP_SERVER'))
|
|
ftp.login(getenv('FTP_USER'), getenv('FTP_PASSWORD'))
|
|
|
|
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()))
|
|
|
|
ftp.storbinary('STOR geofeed.csv', BytesIO(open('geofeed.csv', 'r').read().encode()))
|
|
|
|
# refresh cache
|
|
|
|
url = 'https://api.bunny.net/purge?url=https%3A%2F%2Fdn42.m724.eu&async=false' # replace with your URL
|
|
headers = {
|
|
'AccessKey': getenv("ACCESS_KEY")
|
|
}
|
|
|
|
response = requests.get(url, headers=headers)
|
|
|
|
# Quit ftp
|
|
|
|
ftp.quit() |