Can anyone help me run python scripts with http.server?
Chris Angelico
rosuav at gmail.com
Sun Sep 6 09:23:14 EDT 2015
On Sun, Sep 6, 2015 at 11:07 PM, <tropical.dude.net at gmail.com> wrote:
> I will definitely look into python web frameworks in the future, they seem
> complicated to me compared to php for example. I am looking for the simplest
> way to test my python scripts till I understand better how it works and when
> I can configure my own web server to run the framework because I want develop my
> stuff offline.
Look into Flask. You can do something really simple:
https://github.com/Rosuav/MinstrelHall
All the code is in one file for simplicity, though for a larger
project, you can break it up as required. (Compared to PHP, where
you're _forced_ to have exactly one file per entry-point, this is a
nice flexibility.) Then I just have one line in my Apache config file
that looks something like this:
WSGIScriptAlias / /path/to/scripts/MinstrelHall/mh.wsgi
and Apache does all the rest. There's some cruft in that code to get
around a few oddities, but for the most part, writing a page is as
simple as writing a function, decorated to manage routing, that
returns render_template("somefile.html"). It's pretty easy.
ChrisA
More information about the Python-list
mailing list