mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
cloudflare cache flush wip
This commit is contained in:
parent
ab60bc753b
commit
2e2406c0d6
3 changed files with 23 additions and 1 deletions
|
@ -5,6 +5,7 @@ from random import randint
|
|||
|
||||
import flask
|
||||
import markdown2
|
||||
import requests
|
||||
from sqlalchemy.sql.operators import or_, and_
|
||||
|
||||
from app import db, cache
|
||||
|
@ -276,7 +277,22 @@ def list_files(directory):
|
|||
|
||||
@bp.route('/test')
|
||||
def test():
|
||||
x = find_actor_or_create('artporn@lemm.ee')
|
||||
headers = {
|
||||
'Authorization': f"Bearer {current_app.config['CLOUDFLARE_API_TOKEN']}",
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
body = {
|
||||
'files': ['']
|
||||
}
|
||||
zone_id = current_app.config['CLOUDFLARE_ZONE_ID']
|
||||
response = requests.request(
|
||||
'POST',
|
||||
f'https://api.cloudflare.com/client/v4/zones/{zone_id}/purge_cache',
|
||||
headers=headers,
|
||||
data=body,
|
||||
timeout=5,
|
||||
)
|
||||
|
||||
return 'ok'
|
||||
|
||||
users_to_notify = User.query.join(Notification, User.id == Notification.user_id).filter(
|
||||
|
|
|
@ -46,3 +46,6 @@ class Config(object):
|
|||
SESSION_COOKIE_SECURE = True
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SESSION_COOKIE_SAMESITE = 'Lax'
|
||||
|
||||
CLOUDFLARE_API_TOKEN = os.environ.get('CLOUDFLARE_API_TOKEN') or ''
|
||||
CLOUDFLARE_ZONE_ID = os.environ.get('CLOUDFLARE_ZONE_ID') or ''
|
||||
|
|
|
@ -26,3 +26,6 @@ FLASK_APP = 'pyfedi.py'
|
|||
SENTRY_DSN = ''
|
||||
|
||||
AWS_REGION = 'ap-southeast-2'
|
||||
|
||||
CLOUDFLARE_API_TOKEN = ''
|
||||
CLOUDFLARE_ZONE_ID = ''
|
Loading…
Reference in a new issue