Tuesday, March 10, 2015

Re: fake button run a view and come back to the same page.

El 10/03/15 13:11, dk escribió:
I been trying to find information on how to make a button to run a python script in the back.
I do have a table with some buttons,  and I want to click in one, and behind doors, will run a python script.

since I don't know to much javascript or flask, or php I decided to make a link (later on I can make it look like a button)  that link will run the view witch is my script as subprocess and then
return back again the view of my table,  
so basicly will click the button, will run the code, and redo the view that I was all ready in. something like this.

views:
def main_table(request):
    list_of_files= here I get my files.
    return render(request, "show_table", {"list":list_of_files})
   


def button_do_thing(request):
    file = request.GET.get(file_name)
    dosomething

    main_table(request) # here is where I am actually calling again to the main table to redraw it on the browswer.

but I get the error:
The view mes.views.test_machine didn't return an HttpResponse object. It returned None instead.
I tought passing the request should do it?
  
any tips, tricks?  or an actual way to make the button run the script?

It looks like a perfect time for AJAX.
AngularJS might be an option to do it.

No comments:

Post a Comment