mirror of
https://github.com/quantum5/qlinks.git
synced 2025-04-25 03:01:56 -04:00
Compare commits
No commits in common. "1a60694112a709312b801c2435b249513efdca5d" and "5e2c7e029f12f8731cb19e51505c7baffb0262e3" have entirely different histories.
1a60694112
...
5e2c7e029f
|
@ -1,2 +0,0 @@
|
||||||
import pymysql
|
|
||||||
pymysql.install_as_MySQLdb()
|
|
|
@ -1,16 +1,18 @@
|
||||||
from cloudflare import Cloudflare
|
from CloudFlare import CloudFlare
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from qlinks.cdn_cache import BaseCDNCache
|
from qlinks.cdn_cache import BaseCDNCache
|
||||||
|
|
||||||
|
|
||||||
class CloudflareCDNCache(BaseCDNCache):
|
class CloudflareCDNCache(BaseCDNCache):
|
||||||
cf: Cloudflare
|
cf: CloudFlare
|
||||||
zone: str
|
zone: str
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cf = Cloudflare(api_token=getattr(settings, 'QLINKS_CDN_CLOUDFLARE_API_TOKEN', None))
|
self.cf = CloudFlare(token=getattr(settings, 'QLINKS_CDN_CLOUDFLARE_API_TOKEN', None))
|
||||||
self.zone = settings.QLINKS_CDN_CLOUDFLARE_ZONE_ID
|
self.zone = settings.QLINKS_CDN_CLOUDFLARE_ZONE_ID
|
||||||
|
|
||||||
def purge(self, url: str) -> None:
|
def purge(self, url: str) -> None:
|
||||||
self.cf.cache.purge(zone_id=self.zone, files=[url])
|
self.cf.zones.purge_cache.post(self.zone, data={
|
||||||
|
'files': [url],
|
||||||
|
})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
from django.template import Context
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
# Generated by Django 4.0.1 on 2022-01-24 03:42
|
# Generated by Django 4.0.1 on 2022-01-24 03:42
|
||||||
|
|
||||||
import django.utils.timezone
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Generated by Django 4.0.1 on 2022-01-25 00:13
|
# Generated by Django 4.0.1 on 2022-01-25 00:13
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
import qlinks.models
|
import qlinks.models
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ from functools import partial
|
||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from qlinks.views import health_check, short_link
|
from qlinks.views import short_link
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', partial(short_link, path=''), name='short_link'),
|
path('', partial(short_link, path=''), name='short_link'),
|
||||||
path('api/health_check', health_check, name='health_check'),
|
|
||||||
path('<path:path>', short_link, name='short_link'),
|
path('<path:path>', short_link, name='short_link'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
from qlinks.models import Link
|
from qlinks.models import Link
|
||||||
|
@ -10,8 +10,3 @@ def short_link(request, path):
|
||||||
return HttpResponseRedirect(link, headers={
|
return HttpResponseRedirect(link, headers={
|
||||||
'X-Powered-By': settings.QLINKS_POWERED_BY
|
'X-Powered-By': settings.QLINKS_POWERED_BY
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def health_check(request):
|
|
||||||
Link.objects.exists()
|
|
||||||
return HttpResponse('qlinks seems to work!')
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
Django>=4.2,<5
|
Django>=4,<4.1
|
||||||
django-hosts
|
django-hosts
|
||||||
requests
|
requests
|
||||||
cloudflare
|
|
||||||
|
|
Loading…
Reference in a new issue