Recommended python library/framework for local web app?

前端 未结 10 1664
生来不讨喜
生来不讨喜 2020-12-31 07:33

I want to create a simple LOCAL web app in Python.

The web server and \"back-end\" code will run on the same system (initially, Windows system) as the UI. I doubt it

相关标签:
10条回答
  • 2020-12-31 08:09

    Any framework will do this. Django certainly will do, but since you want something smaller, I'd recommend will BFG/Pyramid, which is very lightweight, extremely extensible and flexible and fun to use. But there are loads of others, and as mentioned, the built in wsgiref is as lightweight as you get. :-)

    0 讨论(0)
  • 2020-12-31 08:20

    I think web2py might be a geat solution here. It requires no installation and has no dependencies (it even comes with its own Python interpreter as well as a web-server and the SQLite database). You can even distribute your application as a Windows or Mac binary (including web2py), and users can easily run it locally with no installation.

    0 讨论(0)
  • 2020-12-31 08:21

    Pylons is extremely easy to use once you get some simple configuration set up, you'll have to have a good idea of what you want though.

    0 讨论(0)
  • 2020-12-31 08:23

    A very simple server in the standard library is wsgiref.simple_server.

    The example looks trivial (demo_app is also part of the module):

    from wsgiref.simple_server import make_server, demo_app
    
    httpd = make_server('', 8000, demo_app)
    print("Serving HTTP on port 8000...")
    
    # Respond to requests until process is killed
    httpd.serve_forever()
    
    0 讨论(0)
  • 2020-12-31 08:23

    I have no direct experience but I've heard some good things about web2py:

    Django vs web2py for a beginner developer

    0 讨论(0)
  • 2020-12-31 08:25

    I've used BaseHTTPServer for this purpose. It's a web server built in to the Python standard library, and lets you have full control over the content you deliver.

    Since it's part of Python's standard library, you don't have to worry about any platform-specific configuration. I've used the same local server script on a Windows, Linux, and Mac OS X system without modification.

    A sample bit of code might be:

    import BaseHTTPServer
    
    class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
        def do_GET(self):
            self.send_response(200)
            self.send_header("Content-type", "text/html")
            self.end_headers()
            self.wfile.write("Hello world!")
    
    server_address = ('', 8080)
    httpd = BaseHTTPServer.HTTPServer(server_address, Handler)
    httpd.serve_forever()
    
    0 讨论(0)
提交回复
热议问题