Issue8004
Created on 2010-02-23 21:22 by djc, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (16) | |||
|---|---|---|---|
| msg99953 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-23 21:22 | |
I'd like to put something like this in Doc, to make it easier to actually review the built documentation. (I guess we could put it in Tools, I'd just like it better if it was right there with the other stuff.)
Good idea? Thomas Wouters kind of liked it but said I should ask you.
from wsgiref.simple_server import make_server
import mimetypes, sys, os
CWD = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.join(CWD, 'build', 'html')
def app(environ, respond):
fn = os.path.join(ROOT, environ['PATH_INFO'][1:])
if '.' not in fn.split(os.path.sep)[-1]:
fn = os.path.join(fn, 'index.html')
type = mimetypes.guess_type(fn)[0]
if os.path.exists(fn):
respond('200 OK', [('Content-Type', type)])
return [open(fn).read()]
else:
respond('404 Not Found', [('Content-Type', 'text/plain')])
return ['not found']
if __name__ == '__main__':
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
httpd = make_server('', port, app)
httpd.serve_forever()
|
|||
| msg99960 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2010-02-23 22:08 | |
How does this make it easier to review the built documentation? Most web browsers are happy to read off disk, and that seems easier than firing up a server. (I would actually have a use case for this, since the machine I build the docs on isn't the machine my web browser runs on; but even there it seems easier to just run firefox remotely (or, in firefox's weird parlance, 'firefox --no-remote').) |
|||
| msg99961 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-23 22:20 | |
I do almost all of my development on servers, so while I guess I could mount the remote file system and do that, that's not very easy to do (since I access my servers from multiple boxes, some of which run Windows, etc). I guess if not many people do that there's not much point, but I figured the script is small and straightforward enough that it might be nice. |
|||
| msg99968 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2010-02-23 23:08 | |
Ah, windows. And if it was there, I'd probably use it. Let's see what Georg things. |
|||
| msg99969 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-23 23:11 | |
Well, even on my MacBook I wouldn't really like having to establish a file mount to my server just to check something out in my browser. |
|||
| msg99971 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-02-23 23:15 | |
Hello Some remarks about the code. 0. The imports do not follow PEP 8 (have one per line, sort by importance (os, sys, wsgiref)). 1. Isn’t there pitfalls with __file__? 2. Can’t you return the file object as WSGI body? Or use a direct sendfile system call? Regards |
|||
| msg99974 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-23 23:24 | |
Sure, I'm happy to fix up the little things. The point is that this works and solves (IMO) a real problem, so I wonder if we can get this in. |
|||
| msg99975 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2010-02-23 23:30 | |
Looks like a nice one for Tools/scripts, and it's a demo of how to use wsgiref too! |
|||
| msg99982 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2010-02-24 00:39 | |
Georg: could we also add a targets in the Docs Makefile and make.bat to fire up the script? |
|||
| msg99983 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-24 00:40 | |
Oh yeah, if we can add a make target I'd be happy to have it live wherever, I guess. That's a great idea. |
|||
| msg100001 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-24 04:12 | |
Fixed in r78416. |
|||
| msg100013 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2010-02-24 09:09 | |
Please add * a docstring for serve.py * a line in scripts/README for it Thanks! |
|||
| msg100014 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-02-24 09:11 | |
Since it’s still new, perhaps the script (and the make target) could be given a more specific name, like docserve. |
|||
| msg100016 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2010-02-24 09:22 | |
The script serves any directory (of HTML files). The Makefile target probably needs no other name since it is already the Doc/Makefile :) |
|||
| msg100017 - (view) | Author: Éric Araujo (eric.araujo) * ![]() |
Date: 2010-02-24 09:24 | |
Indeed, I forgot the hard-coded path has been removed, and didn’t notice the makefile was in Doc. Perfect then, and thanks for pointing these things to my sleepy self :) |
|||
| msg100046 - (view) | Author: Dirkjan Ochtman (djc) * ![]() |
Date: 2010-02-24 17:07 | |
Improved in r78430. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:58 | admin | set | github: 52252 |
| 2010-02-24 17:07:04 | djc | set | messages: + msg100046 |
| 2010-02-24 09:24:47 | eric.araujo | set | messages: + msg100017 |
| 2010-02-24 09:22:43 | georg.brandl | set | messages: + msg100016 |
| 2010-02-24 09:11:39 | eric.araujo | set | messages: + msg100014 |
| 2010-02-24 09:09:52 | georg.brandl | set | messages: + msg100013 |
| 2010-02-24 04:12:38 | djc | set | status: open -> closed resolution: accepted -> fixed messages: + msg100001 |
| 2010-02-24 00:40:24 | djc | set | messages: + msg99983 |
| 2010-02-24 00:39:07 | r.david.murray | set | resolution: accepted messages: + msg99982 versions: + Python 3.2 |
| 2010-02-23 23:30:48 | georg.brandl | set | messages: + msg99975 |
| 2010-02-23 23:24:15 | djc | set | messages: + msg99974 |
| 2010-02-23 23:15:40 | eric.araujo | set | nosy:
+ eric.araujo messages:
+ msg99971 |
| 2010-02-23 23:11:00 | djc | set | messages: + msg99969 |
| 2010-02-23 23:08:17 | r.david.murray | set | nosy:
+ georg.brandl messages: + msg99968 |
| 2010-02-23 22:20:08 | djc | set | messages: + msg99961 |
| 2010-02-23 22:08:56 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg99960 |
| 2010-02-23 21:22:05 | djc | create | |
