替换 FlaskService.py
This commit is contained in:
@@ -25,8 +25,11 @@ def upload_file():
|
||||
filepath = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
|
||||
file.save(filepath)
|
||||
|
||||
appsketch_api = request.form.get('url', 'default_value')
|
||||
pcap_file_id = request.form.get('id', 'default_value')
|
||||
|
||||
# Use PcapNGFormatAnalys.py
|
||||
modified_filepath = modify_file_with_script(filepath)
|
||||
modified_filepath = modify_file_with_script(filepath, appsketch_api, pcap_file_id)
|
||||
|
||||
# Delete uploaded and modified files after response
|
||||
|
||||
@@ -42,11 +45,11 @@ def upload_file():
|
||||
# Provide modified file download
|
||||
return send_file(modified_filepath, as_attachment=True)
|
||||
|
||||
def modify_file_with_script(input_filepath):
|
||||
def modify_file_with_script(input_filepath, appsketch_api, pcap_file_id):
|
||||
modified_filepath = os.path.join(app.config['MODIFIED_FOLDER'], os.path.basename(input_filepath))
|
||||
# Use PcapNGFormatAnalys.py to add Remark
|
||||
script_path = 'PcapNGFormatAnalys.py'
|
||||
subprocess.run(['python', script_path, input_filepath, modified_filepath])
|
||||
subprocess.run(['python3', script_path, input_filepath, modified_filepath, appsketch_api, pcap_file_id])
|
||||
return modified_filepath
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user