From 807cfbf9a5946bb351b6df5897b02757f5b0c62c Mon Sep 17 00:00:00 2001 From: Marco De Donno Date: Fri, 9 Mar 2018 15:18:56 +0100 Subject: [PATCH] Call the process function by default when a file is uploaded --- functions.py | 14 ++++++++++++++ module.py | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 functions.py diff --git a/functions.py b/functions.py new file mode 100644 index 0000000..0a6603c --- /dev/null +++ b/functions.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +from NIST.fingerprint import NISTf_auto + + +def process( wd, filename ): + n = NISTf_auto( wd + "/" + filename ) + + ############################################################################ + # Data export + + with open( wd + "/data.txt", "w+" ) as fp: + fp.write( str( n ) ) diff --git a/module.py b/module.py index 87f13af..2f98e46 100644 --- a/module.py +++ b/module.py @@ -3,12 +3,15 @@ from flask import * from flask_compress import Compress +from threading import Thread from werkzeug import * import logging import os import tempfile +from functions import * + ################################################################################ logging.getLogger().setLevel( logging.INFO ) @@ -63,6 +66,8 @@ def upload_file(): filename = secure_filename( file.filename ) file.save( os.path.join( UPLOAD_FOLDER, filename ) ) + Thread( target = process, args = ( UPLOAD_FOLDER, filename ) ).start() + return jsonify( { 'error': False, 'file': filename } ) ################################################################################ -- GitLab