This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
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
Showing
7 changed files
with
104 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,41 @@ | ||
# coding=utf-8 | ||
|
||
import tornado.ioloop | ||
import tornado.web | ||
|
||
from handlers import dir, file | ||
import settings | ||
|
||
|
||
re_safe_name_with_slash = ur'[ \w\u2e80-\u9fff\-_\.,/]' | ||
|
||
|
||
class MainHandler(tornado.web.RequestHandler): | ||
def get(self): | ||
self.write("Hello, world") | ||
|
||
|
||
application = tornado.web.Application([ | ||
(r'/_admin/', MainHandler), | ||
(r'/_admin/login', MainHandler), | ||
(r'/_admin/logout', MainHandler), | ||
(r'/_admin/upload', MainHandler), | ||
(r'/_admin/mkdir', MainHandler), | ||
(r'/_admin/delete', MainHandler), | ||
(r'/()', dir.DirHandler), | ||
(r'/(%s+/)' % re_safe_name_with_slash, dir.DirHandler), | ||
(r'/(%s+)' % re_safe_name_with_slash, tornado.web.StaticFileHandler, {'path': settings.UPLOAD_PATH}), | ||
]) | ||
|
||
|
||
if __name__ == "__main__": | ||
print """Kuku Start Work! | ||
_ __ _ __ | ||
| | / / | | / / | ||
| |/ / _ _| |/ / _ _ | ||
| \| | | | \| | | | | ||
| |\ \ |_| | |\ \ |_| | | ||
\_| \_/\__,_\_| \_/\__,_| | ||
""" | ||
application.listen(8888) | ||
tornado.ioloop.IOLoop.instance().start() |
Empty file.
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 @@ | ||
|
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,28 @@ | ||
# coding=utf-8 | ||
|
||
import os | ||
|
||
import tornado.ioloop | ||
import tornado.web | ||
|
||
import settings | ||
|
||
|
||
class DirHandler(tornado.web.RequestHandler): | ||
|
||
def get(self, path): | ||
abs_path = os.path.abspath(os.path.join(settings.UPLOAD_PATH, path)) | ||
if settings.UPLOAD_PATH not in abs_path: | ||
raise tornado.web.HTTPError(404) | ||
|
||
dirs = [] | ||
files = [] | ||
l = os.listdir(abs_path) | ||
for f in l: | ||
if os.path.isdir(os.path.join(abs_path, f)): | ||
dirs.append(f) | ||
else: | ||
files.append(f) | ||
|
||
self.write(','.join(dirs) + '; ' + ','.join(files)) | ||
|
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,13 @@ | ||
# coding=utf-8 | ||
|
||
import os | ||
|
||
import tornado.ioloop | ||
import tornado.web | ||
|
||
|
||
class FileHandler(tornado.web.RequestHandler): | ||
|
||
def get(self): | ||
self.write('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,21 @@ | ||
# coding=utf-8 | ||
|
||
import os | ||
|
||
DEBUG = True | ||
|
||
ADMIN = 'alswl' | ||
PASSWORD = '123456' | ||
|
||
ROOT_PATH = os.path.abspath(os.path.dirname(__file__)) | ||
TEMPLATES_PATH = os.path.abspath(os.path.join(ROOT_PATH, 'templates')) | ||
UPLOAD_PATH = os.path.abspath(os.path.join(ROOT_PATH, '..', 'upload')) | ||
|
||
MAX_FILE_SIZE = 5 * 1024 * 1024 # 3 * 1024 * 1024 bytes | ||
ALLOWED_EXTENSIONS = ['jpg', 'png', 'gif', 'zip', 'rar', 'gz'] | ||
|
||
#DEFAULT_DIR_MODE = '755' | ||
#DEFAULT_FILE_MODE = '644' | ||
|
||
#NOT_ALLOWD_NAME = ['admin'] | ||
|