Trigger Download from server side

How can i trigger download from server side.
For example i want to trigger data export in specific format after clicking on button within my form (not using js).
i tried to use this replace pdf and filecontent by my format and my content but it’s not working

	frappe.local.response.filename = "{name}.pdf".format(name=name.replace(" ", "-").replace("/", "-"))
	frappe.local.response.filecontent = get_pdf(html)
	frappe.local.response.type = "download"