mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Initial commit on this broken branch
This commit is contained in:
parent
c668b74ed8
commit
7389b37198
@ -27,6 +27,7 @@ try:
|
||||
from app.classes.web.websocket_handler import SocketHandler
|
||||
from app.classes.web.static_handler import CustomStaticHandler
|
||||
from app.classes.shared.translation import translation
|
||||
from app.classes.web.upload_handler import UploadHandler
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
logger.critical("Import Error: Unable to load {} module".format(e, e.name))
|
||||
@ -129,6 +130,7 @@ class Webserver:
|
||||
(r'/api/stats/servers', ServersStats, handler_args),
|
||||
(r'/api/stats/node', NodeStats, handler_args),
|
||||
(r'/ws', SocketHandler, handler_args),
|
||||
(r'/upload', UploadHandler, handler_args),
|
||||
]
|
||||
|
||||
app = tornado.web.Application(
|
||||
|
34
app/classes/web/upload_handler.py
Normal file
34
app/classes/web/upload_handler.py
Normal file
@ -0,0 +1,34 @@
|
||||
from tornado.concurrent import Future
|
||||
from tornado.escape import utf8
|
||||
from tornado import gen
|
||||
from tornado.httpclient import AsyncHTTPClient
|
||||
from tornado.ioloop import IOLoop
|
||||
from tornado.options import parse_command_line, define, options
|
||||
from tornado.web import Application, RequestHandler, stream_request_body
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
define('server_delay', default=2.0)
|
||||
define('client_delay', default=1.0)
|
||||
define('num_chunks', default=40)
|
||||
|
||||
@stream_request_body
|
||||
class UploadHandler(RequestHandler):
|
||||
def prepare(self):
|
||||
print("In PREPARE")
|
||||
logger.info('UploadHandler.prepare')
|
||||
|
||||
@gen.coroutine
|
||||
def data_received(self, chunk):
|
||||
print("In RECIEVED")
|
||||
logger.info('UploadHandler.data_received(%d bytes: %r)',
|
||||
len(chunk), chunk[:9])
|
||||
yield gen.Task(IOLoop.current().call_later, options.server_delay)
|
||||
|
||||
def put(self):
|
||||
print("In PUT")
|
||||
logger.info('UploadHandler.put')
|
||||
self.write('ok')
|
@ -526,7 +526,7 @@
|
||||
$(function () {
|
||||
server_id = {{ data['server_stats']['server_id']['server_id'] }};
|
||||
var uploadHtml = "<div>" +
|
||||
'<form id="upload_file" enctype="multipart/form-data" action="/ajax/upload_files?id=' + server_id +'&path='+ path +'"method="post">{% raw xsrf_form_html() %}'+"<label class='upload-area' style='width:100%;text-align:center;' for='files'>" +
|
||||
'<form id="upload_file" enctype="multipart/form-data" action="/upload "method="post">{% raw xsrf_form_html() %}'+"<label class='upload-area' style='width:100%;text-align:center;' for='files'>" +
|
||||
"<input id='files' name='files' type='file' style='display:none;' multiple='true'>" +
|
||||
"<i class='fa fa-cloud-upload fa-3x'></i>" +
|
||||
"<br />" +
|
||||
|
Loading…
Reference in New Issue
Block a user