How to implement a minimal server for AJAX in Python?

前端 未结 4 1981
既然无缘
既然无缘 2020-11-27 09:45

I want to create a very simple HTML/AJAX based GUI for a Python program. So the frontend is a HTML page which communicates with the program via AJAX. Can you give me a minim

4条回答
  •  Happy的楠姐
    2020-11-27 10:19

    Thanks for a very intuitive example @nikow I was trying to follow your example, but did get an error:

    (process:10281): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

    I modified your code to meet my needs.

    webbrowser.open('file:///home/jon/workspace/webpages/frontend_example/%s' % FILE)
    // skipped the port part
    httpd = make_server("", 8080, test_app)
    // hardcoded it here.
    

    does my html file has to be put on the webserver ? I have not put it there yet !.

提交回复
热议问题