コード例 #1
0
def browser(urlFilePath):
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "True":
        return redirect(url_for('fit'))
    nestedFilePath = os.path.join(FILE_SYSTEM_ROOT, urlFilePath)
    #nestedFilePath = nestedFilePath.replace("/", "\\")
    if os.path.realpath(nestedFilePath) != nestedFilePath:
        return "no directory traversal please."
    if os.path.isdir(nestedFilePath):
        itemList = os.listdir(nestedFilePath)
        fileProperties = {"filepath": nestedFilePath}
        if not urlFilePath.startswith("/"):
            urlFilePath = "/" + urlFilePath
        return render_template('repos.html',
                               urlFilePath=urlFilePath,
                               itemList=itemList)
    if os.path.isfile(nestedFilePath):
        fileProperties = {"filepath": nestedFilePath}
        sbuf = os.fstat(
            os.open(nestedFilePath,
                    os.O_RDONLY))  #Opening the file and getting metadata
        fileProperties['type'] = stat.S_IFMT(sbuf.st_mode)
        fileProperties['mode'] = stat.S_IMODE(sbuf.st_mode)
        fileProperties['mtime'] = sbuf.st_mtime
        fileProperties['size'] = sbuf.st_size
        if not urlFilePath.startswith("/"):
            urlFilePath = "/" + urlFilePath
        return render_template('file.html',
                               currentFile=nestedFilePath,
                               fileProperties=fileProperties)
    return 'something bad happened'
コード例 #2
0
def browse():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "True":
        return redirect(url_for('fit'))
    itemList = os.listdir(FILE_SYSTEM_ROOT)
    return render_template('repos.html', itemList=itemList)
コード例 #3
0
def settings():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "True":
        return redirect(url_for('fit'))
    if cfgw.read("allowSettings", "SERVERCONFIG", "cfg.ini") == "False":
        return redirect(url_for('index'))
    return render_template('settings.html')
コード例 #4
0
def fit():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "False":
        return redirect(url_for('index'))
    return render_template('fit.html')
コード例 #5
0
def redirect_to_about():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "True":
        return redirect(url_for('fit'))
    return redirect(url_for('index'))
コード例 #6
0
from flask import Flask, render_template, redirect, request, url_for
import os
import stat

import configworker as cfgw

from configparser import ConfigParser

app = Flask(__name__)

wsgi_app = app.wsgi_app

FILE_SYSTEM_ROOT = cfgw.read("fileSystemRoot", "SERVERCONFIG", "cfg.ini")


@app.route('/')
def redirect_to_about():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "True":
        return redirect(url_for('fit'))
    return redirect(url_for('index'))


@app.route('/firstinitsettings')
def fit():
    if cfgw.read("firstInit", "SERVERCONFIG", "cfg.ini") == "False":
        return redirect(url_for('index'))
    return render_template('fit.html')


@app.route('/firstinitsettings', methods=['POST'])
def fit_post():