mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-02 17:48:50 -04:00
Generate letter previews in the new notifications-template-preview service
by calling through to this, we no longer require admin app to ship with binary dependencies (imagemagick/cairo/etc)
This commit is contained in:
17
app/template_previews.py
Normal file
17
app/template_previews.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from flask import current_app, current_service
|
||||
import requests
|
||||
|
||||
|
||||
def get_template_preview(template, filetype):
|
||||
data = {
|
||||
"letter_contact_block": current_service['letter_contact_block'],
|
||||
"admin_base_url": current_app.config['ADMIN_BASE_URL'],
|
||||
"template": template,
|
||||
"values": None
|
||||
}
|
||||
resp = requests.post(
|
||||
'{}/preview.{}'.format(current_app.config['TEMPLATE_PREVIEW_SERVICE_URL'], filetype),
|
||||
json=data,
|
||||
headers={'Authorization': 'Token my-secret-key'}
|
||||
)
|
||||
return (resp.content, resp.status_code, resp.headers.items())
|
||||
Reference in New Issue
Block a user