-1

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

davidism
  • 121,510
  • 29
  • 395
  • 339
lucas
  • 1

2 Answers2

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.

  1. Then you an endpoint for API.
  2. POST the data from frontend to back-end using that API end point.
  3. 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.
Dharman
  • 30,962
  • 25
  • 85
  • 135
Amad
  • 314
  • 1
  • 6
  • 25