mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-06-06 12:29:40 +00:00
Trying to integrate html... One way or another
This commit is contained in:
@@ -4,6 +4,7 @@ import io
|
||||
import sys
|
||||
import struct
|
||||
import fcntl
|
||||
import mimetypes
|
||||
import termios
|
||||
import tornado.websocket
|
||||
import tornado.process
|
||||
@@ -20,6 +21,14 @@ class Index(Route):
|
||||
return self.render('index.html')
|
||||
|
||||
|
||||
@url(r'/file/(.+)')
|
||||
class File(Route):
|
||||
def get(self, file):
|
||||
self.add_header('Content-Type', mimetypes.guess_type(file)[0])
|
||||
with open(file, 'rb') as fd:
|
||||
self.write(fd.read())
|
||||
|
||||
|
||||
@url(r'/ws')
|
||||
class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
|
||||
|
||||
@@ -43,6 +52,9 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
|
||||
env["COLORTERM"] = "wsterm"
|
||||
command = os.getenv('SHELL')
|
||||
env["SHELL"] = command
|
||||
env["PATH"] = "%s:%s" % (
|
||||
os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '..', 'bin')), env["PATH"])
|
||||
p = Popen(command, env=env)
|
||||
p.wait()
|
||||
self.log.info('Exiting...')
|
||||
|
||||
Submodule app/static/javascripts/term.js updated: 948b0e52a2...1db56ba64e
20
bin/ils
Executable file
20
bin/ils
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import mimetypes
|
||||
|
||||
print('\x1b]99;')
|
||||
|
||||
out = ''
|
||||
i = 0
|
||||
|
||||
for f in os.listdir(os.getcwd()):
|
||||
if 'image' in (mimetypes.guess_type(f)[0] or ''):
|
||||
out += '<img src="/file/%s" alt="%s" width="100px" height="100px" />' % (
|
||||
os.path.abspath(f), f)
|
||||
i += 1
|
||||
if i % 5 == 0:
|
||||
out += '\n'
|
||||
|
||||
print(out)
|
||||
|
||||
print('\x07')
|
||||
Reference in New Issue
Block a user