Skip to content

Commit

Permalink
Add assetlinks.json endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoMoreta committed May 22, 2024
1 parent de85d50 commit 5debc1e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
5 changes: 4 additions & 1 deletion appmes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,7 @@
FCM_DJANGO_SETTINGS = {
"ONE_DEVICE_PER_USER": False,
"DELETE_INACTIVE_DEVICES": False,
}
}

# ======= APP Links Configuration ======
ASSETLINKS_FILE = os.path.join(ROOT_DIR, env('ASSETLINKS_FILE'))
7 changes: 6 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
from django.urls import path

from core.views.app_links import AppLinksView

urlpatterns = [
]
path(".well-known/assetlinks.json", AppLinksView.as_view())
]
22 changes: 22 additions & 0 deletions core/views/app_links.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os

from django.conf import settings
from django.http import JsonResponse
from django.views import View


class AppLinksView(View):

def get(self, request, *args, **kwargs):
assetlinks_path = settings.ASSETLINKS_FILE

if not os.path.exists(assetlinks_path):
return JsonResponse({'error': f"File assetlinks.json is missing. {assetlinks_path}"}, status=404)

try:
with open(assetlinks_path, 'r') as file:
file_content = file.read()
except Exception as e:
return JsonResponse({'error': f"An error occurred: {e}"}, status=500)

return JsonResponse({'file_content': file_content})
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- gunicorn_pid:/var/run/gunicorn/
- ../config/logrotate:/etc/logrotate.d
- ../config/firebase:/firebase/
- ../config:/config/
- ../static:/static
- ../media:/media
env_file:
Expand Down

0 comments on commit 5debc1e

Please sign in to comment.