i am creating an website in which the users are going to input some form data and from the form data that the user given i will generate a excel file based on it using python, my python script is already done, but i dont know how i can connect it to the front-end / javascript so the i can pass the data to my python file script download the excel file to the user, i was looking at some django / flask tutorials but haven't found nothing that solves my problem, thanks for any reply in advance
Asked
Active
Viewed 644 times
2 Answers
1
It would be easier if you could show some dummy code you have tried yourself.
So as I understand, you have a script.py ready that will generate the excel file and tested it yourself in command line. But you're not sure how to implement in the Django and get desired results.
Define a function in your views.py
file along the lines of:
def excel_creator(param1,param2):...
- Transform your
script.py
code into the function excel_creator. - Then get the user input (e.g.
request.POST.get()...
) - Call the function and those input values as parameters
- Then work on making the output file downloadable for user (refer Django official documentations).

Pushkar
- 100
- 8
-1
First you need to have a Django or Flask project. Let's say, Django.
- Then you an endpoint for API.
- POST the data from frontend to back-end using that API end point.
- Once the data received on django side, run your script and download the excel file. You can send that excel file to front-end as well for download.