-
Notifications
You must be signed in to change notification settings - Fork 45
added HTML, csv example #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import lob | ||
import csv | ||
import sys | ||
|
||
lob.api_key = 'test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc' | ||
|
||
try: | ||
sys.argv[1] | ||
except IndexError: | ||
print "Please provide an input CSV file as an argument." | ||
sys.exit() | ||
|
||
with open('postcard_front.html', 'r') as frontHtmlFile: | ||
frontHtml = frontHtmlFile.read() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. above you indented 2 spaces, but here it's 4 spaces. shouldn't that cause errors in python? |
||
with open('postcard_back.html', 'r') as backHtmlFile: | ||
backHtml = backHtmlFile.read() | ||
with open(sys.argv[1]) as f: | ||
for row in csv.reader(f): | ||
postcard = lob.Postcard.create( | ||
to_address = { | ||
'name': row[5], | ||
'address_line1': row[6], | ||
'address_line2': row[7], | ||
'address_city': row[8], | ||
'address_state': row[9], | ||
'address_zip': row[10], | ||
'address_country': row[11] | ||
}, | ||
from_address = { | ||
'name': 'Lob', | ||
'address_line1': '123 Main Street', | ||
'address_city': 'San Francisco', | ||
'address_state': 'CA', | ||
'address_zip': '94185', | ||
'address_country': 'US' | ||
}, | ||
setting = 1002, | ||
front = frontHtml, | ||
back = backHtml, | ||
data = { | ||
'background_image': row[1], | ||
'background_color': row[2], | ||
'name': row[0], | ||
'car': row[3], | ||
'mileage': row[4] | ||
} | ||
) | ||
print postcard.url |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Peter,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,LightBlue,Jeep Wrangler,65000,Peter,123 Main Street,Apt. 101,San Francisco,CA,94107,US | ||
Marcus,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Bisque,Honda Pilot,65000,Marcus,456 Oak Street ,Apt. 102,San Francisco,CA,94185,US | ||
Leore,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleGreen,Jeep Wrangler,50000,Leore,123 Test Street,Apt. 101,San Francisco,CA,94105,US | ||
Harry,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Thistle,Jeep Wrangler,50000,Harry,789 Elm Street,Apt. 101,San Francisco,CA,94107,US | ||
Elnaz,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,PaleTurqoise,Jeep Wrangler,35000,Elnaz,111 Washington Street,Apt. 101,San Francisco,CA,94112,US | ||
Robin,https://s3-us-west-2.amazonaws.com/lob-assets/df-car.jpg,Wheat,Jeep Wrangler,35000,Robin,888 Jefferson Street,Apt. 101,San Francisco,CA,94197,US | ||
Russell,https://s3-us-west-2.amazonaws.com/lob-assets/df-car2.jpg,WhiteSmoke,Jeep Wrangler,15000,Russell,1212 Fourth Street,Apt. 101,San Francisco,CA,94166,US |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<html> | ||
<head> | ||
<title>Lob.com Sample 6x11 Postcard Back Template 1</title> | ||
<style> | ||
@font-face { | ||
font-family: 'Arimo'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('https://s3-us-west-2.amazonaws.com/lob-assets/Arimo-Regular.ttf') format('truetype'); | ||
} | ||
|
||
body { | ||
width:11.25in; | ||
height:6.25in; | ||
margin:0; | ||
padding:0; | ||
background-size: 11.25in 6.25in; | ||
} | ||
|
||
#left-box { | ||
font-family: Arimo; | ||
font-size: .25in; | ||
background-color: {{background_color}}; | ||
width: 5.85in; | ||
height: 5.85in; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
padding: .4in .6in 0 .4in; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div id="left-box"> | ||
Hey {{name}},<br><br> | ||
Your {{car}} is due for its {{mileage}} mile service. Schedule an appointment today!<br><br> | ||
Make sure to bring this card to receive great savings!<br><br> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch - updated |
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<html> | ||
<head> | ||
<title>Lob.com Sample 6x11 Postcard Front</title> | ||
<style> | ||
*, *:before, *:after { | ||
-webkit-box-sizing: border-box; | ||
-moz-box-sizing: border-box; | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
width: 11.25in; | ||
height: 6.25in; | ||
margin: 0; | ||
padding: 0; | ||
/* If using an image, the background image should have dimensions of 1875x1275 pixels. */ | ||
background-image: url({{background_image}}); | ||
background-size: 11.25in 6.25in; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
</style> | ||
</head> | ||
|
||
<body> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding the simple ones here as well? @ami