def index(): if request.method == 'PUT' or request.method == 'POST': f = request.form.get('file', '') p = request.form.get('p', '-1') if os.path.isfile(f): with open(f,'r') as rst: d = html_body(rst.read().decode('utf8')) socketio.emit('updatingContent', {'HTML': d,'p':p}) return jsonify(success='true',file=f, p=p) elif p != '-1': socketio.emit('updatingContent', {'p':p}) return jsonify(success='true',file=f, p=p) else: return jsonify(success='false',info='File Not Exist',file=f) elif request.method == 'DELETE': socketio.emit('die', {'exit': 1}) shutdown_server() elif request.method == 'GET': f = request.args.get('file', DEFAULT_FILE) if os.path.isfile(f): with open(f,'r') as rst: d = html_body(rst.read().decode('utf8')) return render_template('index.html',HTML=d, url=URL) else: return render_template('index.html', url=URL)
def index_get(): _file = request.args.get('rst', '') if os.path.isfile(_file): with open(_file, 'r') as _fo: _doc = html_body(_fo.read()) return render_template('index.html', HTML=_doc) else: return render_template('index.html')
def index(): if request.method == 'PUT' or request.method == 'POST': f = request.form.get('file', '') p = request.form.get('p', '-1') _dir = request.form.get('dir', '') print(f) print(p) if _dir: print('_DIR') print(_dir) global DYN_STATIC_DIR DYN_STATIC_DIR = _dir if os.path.isabs(_dir) else os.path.join( os.getcwd(), os.path.dirname(_dir)) if os.path.isfile(f): global DEFAULT_FILE DEFAULT_FILE = f print(DEFAULT_FILE) with open(f, 'r') as rst: d = html_body(rst.read()) socketio.emit('updatingContent', {'HTML': d, 'p': p}) return jsonify(success='true', file=f, p=p) elif p != '-1': socketio.emit('updatingContent', {'p': p}) return jsonify(success='true', file=f, p=p) else: return jsonify(success='false', info='File Not Exist', file=f) elif request.method == 'DELETE': socketio.emit('die', {'exit': 1}) shutdown_server() elif request.method == 'GET': print(DEFAULT_FILE) f = request.args.get('file', DEFAULT_FILE) if os.path.isfile(f): with open(f, 'r') as rst: d = html_body(rst.read()) return render_template('index.html', HTML=d, url=URL) else: return render_template('index.html', url=URL)
def index(): if request.method == 'PUT' or request.method == 'POST': f = request.form.get('file', '') p = request.form.get('p', '-1') _dir = request.form.get('dir', '') print(f) print(p) if _dir: print('_DIR') print(_dir) global DYN_STATIC_DIR DYN_STATIC_DIR = _dir if os.path.isabs(_dir) else os.path.join(os.getcwd(), os.path.dirname(_dir)) if os.path.isfile(f): global DEFAULT_FILE DEFAULT_FILE = f print(DEFAULT_FILE) with open(f,'r') as rst: d = html_body(rst.read()) socketio.emit('updatingContent', {'HTML': d,'p':p}) return jsonify(success='true',file=f, p=p) elif p != '-1': socketio.emit('updatingContent', {'p':p}) return jsonify(success='true',file=f, p=p) else: return jsonify(success='false',info='File Not Exist',file=f) elif request.method == 'DELETE': socketio.emit('die', {'exit': 1}) shutdown_server() elif request.method == 'GET': print(DEFAULT_FILE) f = request.args.get('file', DEFAULT_FILE) if os.path.isfile(f): with open(f,'r') as rst: d = html_body(rst.read()) return render_template('index.html',HTML=d, url=URL) else: return render_template('index.html', url=URL)
def emit_doc(sock, _dir='', _file='', _pos='-1'): _dir = str(_dir) _file = str(_file) _pos = str(_pos) if _dir: settings.STATIC_DIR = getDir(_dir) if os.path.isfile(_file): settings.DEFAULT_FILE = _file with open(_file, 'r') as _fo: _doc = html_body(_fo.read()) sock.emit('updatingContent', {'HTML': _doc, 'pos': _pos}) return True elif _pos != '-1': sock.emit('updatingContent', {'pos': _pos}) return True return False