working download
This commit is contained in:
12
pearcopy.py
12
pearcopy.py
@@ -1,5 +1,12 @@
|
||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||
import json
|
||||
import requests
|
||||
|
||||
def read_book(resp):
|
||||
i=1
|
||||
for item in resp.decode().split(','):
|
||||
print(str(i) + ": " + item)
|
||||
open("{:04d}.jpg".format(i), 'wb').write(requests.get(item).content)
|
||||
i+=1
|
||||
|
||||
|
||||
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
@@ -10,8 +17,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
self.end_headers()
|
||||
#print(body)
|
||||
for item in body.decode().split(','):
|
||||
print(item)
|
||||
read_book(body)
|
||||
|
||||
def do_OPTIONS(self):
|
||||
print(self.headers)
|
||||
|
||||
Reference in New Issue
Block a user