在javascript中我使用ajax进行POST,我需要从我的Python程序中获得回复。以下代码显示了javascript,但是如何在Python端从GET生成所需的self.response.out.write(template.render( template_values))
return webapp2.redirect("/templatename/%s" % variable)
?
在此示例中,我想要对用户提出是否更改提供的名称的问题的是或否回复。
我理解如何在python POST中接收名称和值,但我不知道如何在相关的python GET中生成响应。
from tkinter import *
print("aa")
def customerwindow():
root1 = Tk()
root1.title("Customer Choice")
window_width = 1000
window_height = 600
screen_height = root1.winfo_screenheight()
screen_width = root1.winfo_screenwidth()
x_coordinate = (screen_width / 2) - (window_width / 2)
y_coordinate = (screen_height / 2) - (window_height / 2)
root1.geometry('%dx%d+%d+%d' % (window_width, window_height, x_coordinate, y_coordinate))
frame1 = Frame(root1, height=1000, width=600)
frame1.pack(fill=BOTH)
Order = PhotoImage(file="fast-food.png")
Cancel = PhotoImage(file="delete.png")
OrderButton = Button(frame1, image=Order)
OrderButton.place(x=152, y=125)
CancelButton = Button(frame1, image=Cancel)
CancelButton.place(x=550, y=125)
OrderLabel = Label(frame1, text=" ORDER", font=("Poiret One", 24), fg='#34495E')
CancelLabel = Label(frame1, text=" CANCEL ORDER", font=("Poiret One", 24), fg='#34495E')
OrderLabel.place(x=152, y=405)
CancelLabel.place(x=550, y=405)
mainloop()
print("bb")
def welcomeWindow():
root = Tk()
root.title("Welcome")
window_width = 1000
window_height = 600
screen_height = root.winfo_screenheight()
screen_width = root.winfo_screenwidth()
x_coordinate = (screen_width/2) - (window_width/2)
y_coordinate = (screen_height/2) - (window_height/2)
root.geometry('%dx%d+%d+%d' % (window_width, window_height, x_coordinate, y_coordinate))
frame1 = Frame(root, height=1000, width=600)
frame1.pack(fill=BOTH)
customerPhoto = PhotoImage(file="boy.png")
staffPhoto = PhotoImage(file="boss.png")
customerButton = Button(frame1, image=customerPhoto, command=customerwindow)
customerButton.place(x=152, y=125)
staffButton = Button(frame1, image=staffPhoto)
staffButton.place(x=550, y=125)
customerLabel = Label(frame1, text=" CUSTOMER", font=("Poiret One", 24), fg='#34495E')
staffLabel = Label(frame1, text=" STAFF", font=("Poiret One", 24), fg='#34495E')
customerLabel.place(x=152, y=405)
staffLabel.place(x=550, y=405)
mainloop()
welcomeWindow()
print("SS")
#aa,bb,ss are just to check the interpreters progress.
我在Python GET中的典型响应遵循以下两种模式之一,但在这种情况下似乎都不允许我回复。
public function getFunctionFromUserGroup(Request $request)
{
try
{
$abc = $request->get('usertypeid');
return response() ->
json (SystemFunction::whereNotIn('Function_ID',
function ($q){
$q->select('Function_ID')
->from('TB_UserAccess')
->Where('UserType_ID', $abc );})->get(), 200);
}
catch (\Exception $e)
{
return response(['error'=> $e->getMessage()], 422);
}
}
(请不要PHP或jquery。)