<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def preview(file):
 """Render appropriate template with embed flag."""

    params = deepcopy(current_app.config['IIIF_PREVIEWER_PARAMS'])
    if 'image_format' not in params:
        params['image_format'] = \
            'png' if file.has_extensions('.png') else 'jpg'
    return render_template(
        current_app.config['IIIF_PREVIEW_TEMPLATE'],
        file=file,
        file_url=ui_iiif_image_url(
            file.file,
            **params
        )
    )