66 lines
2.3 KiB
Python
Executable File
66 lines
2.3 KiB
Python
Executable File
from django.contrib import admin
|
|
from django.urls import path, include
|
|
from django.conf import settings
|
|
from django.conf.urls.static import static
|
|
|
|
from django.http import HttpResponse
|
|
|
|
def view_logs(request):
|
|
log_file_path = '/home/mnfbeta/mnf/app/media/gunicorn.err.log'
|
|
lines_to_read = 200
|
|
|
|
try:
|
|
with open(log_file_path, 'r') as log_file:
|
|
log_file.seek(0, 2) # Seek to the end of the file
|
|
lines = []
|
|
line_count = 0
|
|
pos = log_file.tell()
|
|
|
|
while line_count < lines_to_read and pos > 0:
|
|
log_file.seek(pos, 0)
|
|
next_char = log_file.read(1)
|
|
if next_char == "\n":
|
|
line = log_file.readline().strip()
|
|
lines.insert(0, line)
|
|
line_count += 1
|
|
pos -= 1
|
|
|
|
log_contents = '\n'.join(lines)
|
|
return HttpResponse(log_contents, content_type='text/plain')
|
|
except FileNotFoundError:
|
|
return HttpResponse('Log file not found', status=404)
|
|
except Exception as e:
|
|
return HttpResponse(f'Error reading log file: {str(e)}', status=500)
|
|
|
|
|
|
urlpatterns = [
|
|
path('admin/', admin.site.urls),
|
|
path('log/', view_logs),
|
|
#path('accounts/', include('allauth.urls')),
|
|
#path('accounts/', include('allauth.socialaccount.urls')),
|
|
path('', include('prelogin.urls')),
|
|
path('', include('users.urls')),
|
|
path('mnfapp/',include('mnfapp.urls')),
|
|
# path("viewerlounge/", include("viewerLounge.urls")),
|
|
# path("harkat/", include("harkat.urls")),
|
|
# path("ideamall/", include("ideamall2.urls")),
|
|
path("lpp/", include("lpp.urls")),
|
|
# path("memberpage/", include("memberpage.urls")),
|
|
path("pay/", include("payment.urls")),
|
|
# path('rhm/',include("rhm.urls")),
|
|
# path("scriptpad2/",include("ScriptPad2.urls")),
|
|
path("audit/",include("scriptAudit.urls")),
|
|
# path("blockchain/", include("Blockchain2.urls")),
|
|
# path("rm/", include("relationshipmanager.urls")),
|
|
path("conversion/", include("conversion.urls")),
|
|
path("auto_email/", include("auto_email.urls")),
|
|
path("juggernaut/", include("juggernaut.urls")),
|
|
# path("institute/", include("institutional.urls")),
|
|
|
|
|
|
]
|
|
|
|
if settings.DEBUG:
|
|
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
|
|
|