Spaces:
Runtime error
Runtime error
thejagstudio
commited on
Commit
•
7f12d33
1
Parent(s):
3a9c601
Update home/views.py
Browse files- home/views.py +21 -0
home/views.py
CHANGED
@@ -160,6 +160,27 @@ def uploader(request):
|
|
160 |
thread.join()
|
161 |
return redirect('/upload/')
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
@csrf_exempt
|
165 |
@login_required
|
|
|
160 |
thread.join()
|
161 |
return redirect('/upload/')
|
162 |
|
163 |
+
@csrf_exempt
|
164 |
+
def uploaderAI(request):
|
165 |
+
global gauth
|
166 |
+
if gauth.access_token_expired:
|
167 |
+
# Refresh them if expired
|
168 |
+
gauth.Refresh()
|
169 |
+
if request.method == 'POST':
|
170 |
+
try:
|
171 |
+
file = request.FILES['file']
|
172 |
+
title = request.POST['title']
|
173 |
+
prompt = request.POST['prompt']
|
174 |
+
if title == '':
|
175 |
+
title = file.name
|
176 |
+
folder_id = "1Hxpc5aT4xl9Nz1QUQJirJcnaT9J1QrzR"
|
177 |
+
file1 = DRIVE.CreateFile({'title': title, 'description':prompt, 'parents': [{'id': folder_id}]})
|
178 |
+
file1.content = file
|
179 |
+
file1.Upload()
|
180 |
+
return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
|
181 |
+
except Exception as e:
|
182 |
+
return HttpResponse(json.dumps({'status': 'error','error':str(e)}), content_type='application/json')
|
183 |
+
|
184 |
|
185 |
@csrf_exempt
|
186 |
@login_required
|