Skip to content
Snippets Groups Projects
Commit fc682dc8 authored by Adam Drake's avatar Adam Drake
Browse files

Model photo upload working and sent to view method

parent d861edb5
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -11,5 +11,13 @@
<h2>Model Layers: {{ layer }}</h2>
<form action="/mlmodel/{{ modelID }}/" method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="photo" id="photoInput" accept="image/*">
<button type="submit">Upload Photo</button>
</form>
</div>
from django.shortcuts import render, redirect
from django.http import HttpResponse
from django.contrib import messages
from django.contrib.auth.decorators import login_required
# messages.debug
......@@ -119,6 +119,16 @@ import base64
@login_required
def mlmodel(request, pk):
if request.method == "POST":
# Handle form submission here
# For example, you can process the uploaded file
uploaded_file = request.FILES['photo']
# Process the uploaded file as needed
# Return a response indicating successful upload
return HttpResponse("<h1> You uploaded your photo ! </h1>")
else:
matrix = np.asarray([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
......@@ -166,4 +176,5 @@ def mlmodel(request, pk):
layercount = str(mlmodel.layers)
return render(request, "prediction_service/model.html", {'img_str': img_str,
'layer': layercount,})
\ No newline at end of file
'layer': layercount,
'modelID': pk})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment