[tor-commits] [atlas/master] Remove run.py because shipping a web server goes beyond the scope of what atlas

karsten at torproject.org karsten at torproject.org
Thu Aug 8 07:36:18 UTC 2013


commit e4fdd177ac54a84263e621c8927c6ffb7c2cabe7
Author: Philipp Winter <phw at torproject.org>
Date:   Tue Aug 6 18:44:20 2013 +0200

    Remove run.py because shipping a web server goes beyond the scope of what atlas
    should provide.
---
 run.py |  104 ----------------------------------------------------------------
 1 file changed, 104 deletions(-)

diff --git a/run.py b/run.py
deleted file mode 100644
index 3e534f5..0000000
--- a/run.py
+++ /dev/null
@@ -1,104 +0,0 @@
-from __future__ import with_statement
-
-import Cookie
-import base64
-import binascii
-import calendar
-import datetime
-import email.utils
-import functools
-import gzip
-import hashlib
-import hmac
-import httplib
-import itertools
-import logging
-import mimetypes
-import os.path
-import re
-import stat
-import sys
-import time
-import tornado
-import traceback
-import types
-import urllib
-import urlparse
-import uuid
-
-from tornado import escape
-from tornado import locale
-from tornado import stack_context
-from tornado import template
-from tornado.escape import utf8, _unicode
-from tornado.util import b, bytes_type, import_object, ObjectDict
-
-try:
-    from io import BytesIO  # python 3
-except ImportError:
-    from cStringIO import StringIO as BytesIO  # python 2
-
-from tornado import web, ioloop
-from tornado.web import HTTPError
-import datetime
-import os
-
-class LongStatic(web.StaticFileHandler):
-
-    def get(self, path, include_body=True):
-        if os.path.sep != "/":
-            path = path.replace("/", os.path.sep)
-        abspath = os.path.abspath(os.path.join(self.root, path))
-        # os.path.abspath strips a trailing /
-        # it needs to be temporarily added back for requests to root/
-        if not (abspath + os.path.sep).startswith(self.root):
-            raise HTTPError(403, "%s is not in root static directory", path)
-        if os.path.isdir(abspath) and self.default_filename is not None:
-            # need to look at the request.path here for when path is empty
-            # but there is some prefix to the path that was already
-            # trimmed by the routing
-            if not self.request.path.endswith("/"):
-                self.redirect(self.request.path + "/")
-                return
-            abspath = os.path.join(abspath, self.default_filename)
-        if not os.path.exists(abspath):
-            raise HTTPError(404)
-        if not os.path.isfile(abspath):
-            raise HTTPError(403, "%s is not a file", path)
-
-        stat_result = os.stat(abspath)
-        modified = datetime.datetime.fromtimestamp(stat_result[stat.ST_MTIME])
-
-        mime_type, encoding = mimetypes.guess_type(abspath)
-        if mime_type:
-            self.set_header("Content-Type", mime_type)
-
-        cache_time = self.get_cache_time(path, modified, mime_type)
-
-        self.set_extra_headers(path)
-
-        # Check the If-Modified-Since, and don't send the result if the
-        # content has not been modified
-        ims_value = self.request.headers.get("If-Modified-Since")
-        if ims_value is not None:
-            date_tuple = email.utils.parsedate(ims_value)
-            if_since = datetime.datetime.fromtimestamp(time.mktime(date_tuple))
-            #if if_since >= modified:
-            #    self.set_status(304)
-            #    return
-
-        if not include_body:
-            return
-        file = open(abspath, "rb")
-        try:
-            self.write(file.read())
-        finally:
-            file.close()
-
-
-rest_api = [(r"/(.*)", LongStatic, {"path": "./"})]
-
-if __name__ == "__main__":
-    application = web.Application(rest_api)
-    application.listen(8888)
-    ioloop.IOLoop.instance().start()



More information about the tor-commits mailing list