Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,26 @@ def get_pdf_content():
|
|
16 |
# Convert Google Drive link to direct download link
|
17 |
file_id = COURSE_PDF_URL.split('/')[5]
|
18 |
direct_url = f"https://drive.google.com/uc?export=download&id={file_id}"
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
except Exception as e:
|
21 |
print(f"Error loading PDF: {e}")
|
22 |
return None
|
|
|
16 |
# Convert Google Drive link to direct download link
|
17 |
file_id = COURSE_PDF_URL.split('/')[5]
|
18 |
direct_url = f"https://drive.google.com/uc?export=download&id={file_id}"
|
19 |
+
response = httpx.get(direct_url)
|
20 |
+
|
21 |
+
# Add verification
|
22 |
+
if response.status_code == 200:
|
23 |
+
content = response.content
|
24 |
+
content_type = response.headers.get('content-type', '')
|
25 |
+
|
26 |
+
print(f"PDF Download Status: Success")
|
27 |
+
print(f"Content Type: {content_type}")
|
28 |
+
print(f"Content Size: {len(content)} bytes")
|
29 |
+
|
30 |
+
if 'pdf' in content_type.lower() or content[:4] == b'%PDF':
|
31 |
+
return content
|
32 |
+
else:
|
33 |
+
print("Warning: Downloaded content might not be a PDF")
|
34 |
+
return None
|
35 |
+
else:
|
36 |
+
print(f"Failed to download PDF. Status code: {response.status_code}")
|
37 |
+
return None
|
38 |
+
|
39 |
except Exception as e:
|
40 |
print(f"Error loading PDF: {e}")
|
41 |
return None
|