add threaded WSGI server mixin to check URL existence on same host :>

This commit is contained in:
posativ 2012-12-16 00:46:20 +01:00
parent 63b990838d
commit 8e2e90ed4e
3 changed files with 12 additions and 4 deletions

View File

@ -50,7 +50,7 @@ class Isso(object):
MODERATION = False
SQLITE = None
HOST = 'http://localhost:8000/'
HOST = 'http://localhost:8080/'
MAX_AGE = 15 * 60
HTTP_STATUS_CODES = {
@ -189,5 +189,5 @@ def main():
else:
from wsgiref.simple_server import make_server
httpd = make_server('127.0.0.1', 8080, app)
httpd = make_server('127.0.0.1', 8080, app, server_class=wsgi.ThreadedWSGIServer)
httpd.serve_forever()

View File

@ -13,7 +13,8 @@ from isso import json, models, utils, wsgi
def create(app, environ, request, path):
if app.PRODUCTION and not utils.urlexists(app.HOST, '/' + path):
if app.PRODUCTION and not utils.urlexists(app.HOST, path):
print app.HOST, path
return 400, 'URL does not exist', {}
try:

View File

@ -5,12 +5,15 @@ import io
import os
import re
import cgi
import wsgiref
import tempfile
import urlparse
import mimetypes
from Cookie import SimpleCookie
from urllib import quote
from Cookie import SimpleCookie
from SocketServer import ThreadingMixIn
from wsgiref.simple_server import WSGIServer
class Request(object):
@ -119,3 +122,7 @@ def sendfile(filename, root):
def setcookie(name, value, **kwargs):
return '; '.join([quote(name, '') + '=' + quote(value, '')] +
[k.replace('_', '-') + '=' + str(v) for k, v in kwargs.iteritems()])
class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
pass