forked from benoitc/pistil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
benoitc
committed
Aug 4, 2011
0 parents
commit e65e005
Showing
22 changed files
with
1,744 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
*.gem | ||
*.swp | ||
*.pyc | ||
*#* | ||
build | ||
dist | ||
setuptools-* | ||
.svn/* | ||
.DS_Store | ||
*.so | ||
distribute-0.6.8-py2.6.egg | ||
distribute-0.6.8.tar.gz | ||
pistil.egg-info | ||
nohup.out | ||
.coverage | ||
doc/.sass-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
2011 (c) Benoît Chesneau <[email protected]> | ||
2011 (c) Meebo | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include .gitignore | ||
include LICENSE | ||
include NOTICE | ||
include README.rst | ||
include THANKS | ||
|
||
recursive-include examples * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Pistil | ||
|
||
2011 (c) Benoît Chesneau <[email protected]> | ||
2011 (c) Meebo | ||
|
||
Pistil is released under the MIT license. See the LICENSE | ||
file for the complete license. | ||
|
||
|
||
Following files are under MIT License and copyrights: | ||
2009-2011 (c) Benoît Chesneau <[email protected]> | ||
2009-2011 (c) Paul J. Davis <[email protected]> | ||
|
||
|
||
pistil/arbiter.py, | ||
pistil/util.py | ||
pistil/sock.py | ||
pistil/pidfile.py | ||
pistil/workertmp.py | ||
pistil/worker.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pistil | ||
------ | ||
|
||
|
||
Simple multiprocessing toolkit. This is based on the `Gunicorn <http://gunicorn.orh>`_ multiprocessing engine. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# -*- coding: utf-8 - | ||
# | ||
# This file is part of gunicorn released under the MIT license. | ||
# See the NOTICE for more information. | ||
|
||
import mimetypes | ||
import os | ||
|
||
from http_parser.http import HttpStream | ||
from http_parser.reader import SocketReader | ||
|
||
from pistil import util | ||
from pistil.tcp.arbiter import TcpArbiter | ||
from pistil.tcp.gevent_worker import TcpGeventWorker | ||
|
||
CURDIR = os.path.dirname(__file__) | ||
|
||
|
||
def write_error(sock, status_int, reason, mesg): | ||
html = textwrap.dedent("""\ | ||
<html> | ||
<head> | ||
<title>%(reason)s</title> | ||
</head> | ||
<body> | ||
<h1>%(reason)s</h1> | ||
%(mesg)s | ||
</body> | ||
</html> | ||
""") % {"reason": reason, "mesg": mesg} | ||
|
||
http = textwrap.dedent("""\ | ||
HTTP/1.1 %s %s\r | ||
Connection: close\r | ||
Content-Type: text/html\r | ||
Content-Length: %d\r | ||
\r | ||
%s | ||
""") % (str(status_int), reason, len(html), html) | ||
write_nonblock(sock, http) | ||
|
||
|
||
|
||
class HttpWorker(TcpGeventWorker): | ||
|
||
def handle(self, sock, addr): | ||
p = HttpStream(SocketReader(sock)) | ||
|
||
path = p.path() | ||
|
||
if not path or path == "/": | ||
path = "index.html" | ||
|
||
if path.startswith("/"): | ||
path = path[1:] | ||
|
||
real_path = os.path.join(CURDIR, "static", path) | ||
if not os.path.exists(real_path): | ||
util.write_error(sock, 404, "Not found", real_path + " not found") | ||
else: | ||
ctype = mimetypes.guess_type(real_path) | ||
|
||
with open(real_path, 'r') as f: | ||
resp = "".join(["HTTP/1.1 200 OK\r\n", | ||
"Content-Type: " + ctype[0] + "\r\n", | ||
"Connection: close\r\n\r\n", | ||
f.read()]) | ||
sock.sendall(resp) | ||
|
||
|
||
def main(): | ||
conf = {"address": ("127.0.0.1", 5000), "debug": True} | ||
print conf | ||
arbiter = TcpArbiter(conf, HttpWorker) | ||
arbiter.run() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Welcome ! | ||
|
||
Go to <a href="hello.html">Hello world</a>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- coding: utf-8 - | ||
# | ||
# This file is part of pistil released under the MIT license. | ||
# See the NOTICE for more information. | ||
|
||
|
||
version_info = (0, 1,0) | ||
__version__ = ".".join(map(str, version_info)) | ||
|
||
SERVER_SOFTWARE = "pistil/%s" % __version__ |
Oops, something went wrong.