refactor code dir

rename backend/ to api/, remove leftover dir ui/
This commit is contained in:
Joel Mathew Thomas
2025-01-09 11:39:56 +05:30
parent 3d0dfcd42b
commit 2608391608
147 changed files with 0 additions and 5640 deletions
View File
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
+12
View File
@@ -0,0 +1,12 @@
from django import forms
class UploadFileForm(forms.Form):
file = forms.FileField(label='Select a file')
# You can add custom validation if needed
def clean_file(self):
file = self.cleaned_data.get('file')
if not file:
raise forms.ValidationError("No file uploaded!")
# Additional custom validations can be added here
return file
View File
+3
View File
@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.
+11
View File
@@ -0,0 +1,11 @@
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from src.input.file_reader import read_audio #export PYTHONPATH="/home/karthikeyan/code/MainProject/freq-split-enhance:$PYTHONPATH" for exporting the module
import time
@shared_task
def process_uploaded_file(file_path):
# Simulate long-running task
read_audio(file_path=file_path)
return 'File processed'
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+31
View File
@@ -0,0 +1,31 @@
from django.shortcuts import render
from django.http import JsonResponse
from .tasks import process_uploaded_file
from .forms import UploadFileForm
import os
# Create your views here.
def handle_uploaded_file(f, file_path):
with open(file_path, 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
def upload(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
file = form.cleaned_data['file']
file_path = os.path.join('uploads', file.name) # Change 'uploads' to your desired directory
handle_uploaded_file(file, file_path)
task = process_uploaded_file.delay(file_path)
return JsonResponse({'task_id': task.id})
else:
form = UploadFileForm()
return render(request, 'upload.html', {'form': form})
from celery.result import AsyncResult
def check_task_status(request, task_id):
task_result = AsyncResult(task_id)
return JsonResponse({'status': task_result.status, 'result': task_result.result})