b9137204a0
- FilePreview.vue: add normalizedFileType computed to handle backend returning uppercase HTML/MD/PPTX (fixes preview/download buttons) - FilePreview.vue: bg-gradient-to-r from-orange-500 -> bg-orange-500 (Tailwind v4 gradient + CSS variable = transparent) - ReportCard.vue: bg-gradient-to-r -> bg-orange-600 for selected state - Add .opencode/, node_modules/, dist/ to .gitignore - Initial git setup for publish project
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
import urllib.request
|
|
import json
|
|
import io
|
|
|
|
# Get first project
|
|
req = urllib.request.Request('http://localhost:37821/api/projects/1')
|
|
resp = urllib.request.urlopen(req)
|
|
project = json.loads(resp.read().decode())
|
|
print('Project before:', project)
|
|
|
|
# Create a small test PNG image (1x1 pixel)
|
|
png_data = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\x0f\x00\x00\x00\x01\x00\x01\x00\x05\xfe\x02\xfe\x00\x00\x00\x00IEND\xaeB`\x82'
|
|
|
|
# Upload cover image
|
|
boundary = '----FormBoundary7MA4YWxkTrZu0gW'
|
|
data = '--{}\r\nContent-Disposition: form-data; name="name"\r\n\r\nTest Project\r\n--{}\r\nContent-Disposition: form-data; name="coverImage"; filename="test.png"\r\nContent-Type: image/png\r\n\r\n'.format(boundary, boundary).encode() + png_data + '\r\n--{}--\r\n'.format(boundary).encode()
|
|
|
|
req = urllib.request.Request(
|
|
'http://localhost:37821/api/projects/1',
|
|
data=data,
|
|
headers={
|
|
'Content-Type': 'multipart/form-data; boundary=' + boundary,
|
|
},
|
|
method='PUT'
|
|
)
|
|
|
|
try:
|
|
resp = urllib.request.urlopen(req)
|
|
result = json.loads(resp.read().decode())
|
|
print('Upload response:', result)
|
|
print('coverImage:', result.get('coverImage'))
|
|
except Exception as e:
|
|
print('Error uploading:', e)
|
|
|
|
# Check updated project
|
|
req2 = urllib.request.Request('http://localhost:37821/api/projects/1')
|
|
resp2 = urllib.request.urlopen(req2)
|
|
project2 = json.loads(resp2.read().decode())
|
|
print('Project after:', project2) |