mirror of
https://github.com/quantum5/qlinks.git
synced 2025-04-24 10:41:57 -04:00
Compare commits
5 commits
5e2c7e029f
...
1a60694112
Author | SHA1 | Date | |
---|---|---|---|
|
1a60694112 | ||
|
7ff577fd0c | ||
|
dea0154077 | ||
|
971854f4c1 | ||
|
22f2a9761a |
2
pymysql_as_mysql.py
Normal file
2
pymysql_as_mysql.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
import pymysql
|
||||||
|
pymysql.install_as_MySQLdb()
|
|
@ -1,18 +1,16 @@
|
||||||
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(token=getattr(settings, 'QLINKS_CDN_CLOUDFLARE_API_TOKEN', None))
|
self.cf = Cloudflare(api_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.zones.purge_cache.post(self.zone, data={
|
self.cf.cache.purge(zone_id=self.zone, files=[url])
|
||||||
'files': [url],
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
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,9 +1,8 @@
|
||||||
# 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,6 +1,7 @@
|
||||||
# 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,9 +2,10 @@ from functools import partial
|
||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from qlinks.views import short_link
|
from qlinks.views import health_check, 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 HttpResponseRedirect
|
from django.http import HttpResponse, 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,3 +10,8 @@ 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,3 +1,4 @@
|
||||||
Django>=4,<4.1
|
Django>=4.2,<5
|
||||||
django-hosts
|
django-hosts
|
||||||
requests
|
requests
|
||||||
|
cloudflare
|
||||||
|
|
Loading…
Reference in a new issue