Tweaks to file_server initialisation
We are setting a sensible default for the storage folder and loading that automatically, this way we avoid having a compulsory config file.
This commit is contained in:
@@ -3,7 +3,8 @@ import os
|
||||
from flask import Blueprint
|
||||
from flask import request
|
||||
|
||||
import config
|
||||
from application import app
|
||||
|
||||
|
||||
file_server = Blueprint('file_server', __name__,
|
||||
template_folder='templates',
|
||||
@@ -22,10 +23,10 @@ def index(file_name=None):
|
||||
#POST file
|
||||
file_name = request.form['name']
|
||||
folder_name = file_name[:2]
|
||||
file_folder_path = os.path.join(config.Development.FILE_STORAGE,
|
||||
file_folder_path = os.path.join(app.config['FILE_STORAGE'],
|
||||
folder_name)
|
||||
if not os.path.exists(file_folder_path):
|
||||
os.mkdir(file_folder_path)
|
||||
os.mkdir(file_folder_path)
|
||||
file_path = os.path.join(file_folder_path, file_name)
|
||||
request.files['data'].save(file_path)
|
||||
|
||||
|
Reference in New Issue
Block a user