Recommended python library/framework for local web app?

前端 未结 10 1665
生来不讨喜
生来不讨喜 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:25

    I have written a handful of such "local web server" apps since I asked this question. I don't have a final "which framework is best" answer, but I do have some insights:

    1. A simple or micro-framework is indeed a good choice.
    2. I've tried CherryPy and Flask frameworks. Flask is the clear winner for simplicity, with basic "set up some AJAX serving pages" functions entirely trivial to write in Flask. CherryPy documentation is often opaque, and its setup complexity notably higher.
    3. I'm happy with Flask, but I continue to look around. I would especially like to try Bottle, which I've seen reviewed very highly, including in other StackOverflow discussions and this side-by-side comparison: http://www.slideshare.net/r1chardj0n3s/web-microframework-battle web2py also looks worth a try.
    0 讨论(0)
  • 2020-12-31 08:29

    Django comes with a built-in web server that allows you to fully test your application locally (via localhost:8080 or something of the sort). As a matter of fact, I've used it more than once to run a complete web-application locally prior to deploying it to a server. I see no reason you can't use it for your own local web-app purposes. Although it may seem that Django is big and complex, this solution is self-contained and simple to run:

    1. Install Django
    2. Go through the great tutorial, which very soon shows you how to run the web-server
    3. Write your code

    That's about it. Deploying it to other machines is also simple to do, especially with something like virtualenv.

    If you don't want a large web-framework at all, I'll have to join Greg's advice to use BaseHTTPServer. I've used it before for specialized local applications and it's working well, doing what's expected from it and not much more. It's a very flexible solution allowing you to build something quite custom if you need it.

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

    Bottle is a very lightweight micro-framework. It comes as a single .py-file with no external dependencies, supports routing, a small template-engine and comes with an integrated webserver. It is easy to use and slim.

    This sounds like a perfect match to your requirements :)

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

    chances are, you want an admin interface for basic CRUD operations on some database tables. Then Django is your best choice.

    0 讨论(0)
提交回复
热议问题