Make the fastapi application the main asgi one.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
"""
|
||||
ASGI config for etebase_server project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "etebase_server.settings")
|
||||
django_application = get_asgi_application()
|
||||
|
||||
application = get_asgi_application()
|
||||
|
||||
def create_application():
|
||||
from etebase_fastapi.main import app
|
||||
|
||||
app.mount("/", django_application)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
application = create_application()
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.urls import path, re_path
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.static import serve
|
||||
from django.contrib.staticfiles import finders
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^api/", include("django_etebase.urls")),
|
||||
@@ -14,3 +18,12 @@ if settings.DEBUG:
|
||||
urlpatterns += [
|
||||
url(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")),
|
||||
]
|
||||
|
||||
def serve_static(request, path):
|
||||
filename = finders.find(path)
|
||||
dirname = os.path.dirname(filename)
|
||||
basename = os.path.basename(filename)
|
||||
|
||||
return serve(request, basename, dirname)
|
||||
|
||||
urlpatterns += [re_path(r"^static/(?P<path>.*)$", serve_static)]
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
"""
|
||||
WSGI config for etebase_server project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "etebase_server.settings")
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user