-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from flask import Flask, request, jsonify | ||
import os | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/upload', methods=['POST']) | ||
def upload_file(): | ||
print(request.files) | ||
print(request.form) | ||
if 'file' not in request.files: | ||
return jsonify({'error': 'No file part'}), 400 | ||
file = request.files['file'] | ||
folder = './uploads/'+request.form['folder'].replace(':','') | ||
|
||
if file.filename == '': | ||
return jsonify({'error': 'No selected file'}), 400 | ||
|
||
if file: | ||
if os.path.exists(folder): | ||
print("\nDRRRRDD\n") | ||
else: | ||
print('\nDDD\n') | ||
os.makedirs(folder,exist_ok=True) | ||
|
||
|
||
file_path = os.path.join(folder, file.filename) | ||
|
||
file.save(file_path) | ||
|
||
# Example of processing additional data | ||
additional_data = request.form.to_dict() | ||
|
||
return jsonify({'message': 'File and data received successfully', 'data': additional_data}), 200 | ||
|
||
|
||
|
||
@app.route('/makefolder', methods=['POST']) | ||
def make_folder(): | ||
if 'folder' not in request.form: | ||
return jsonify({'error': 'No file part'}), 400 | ||
folder = request.form['folder'] | ||
os.mkdir('./uploads/'+folder) | ||
# Example of processing additional data | ||
return jsonify({'message': 'Folder added successfully', 'data':folder }), 200 | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
curl -v -F file=@%1 -F folder=%~dp1 http://localhost:5000/upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
curl -v -F file=@%1 -F folder=%~dp2 http://localhost:5000/upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
REM dir /A-D /S /B >> r.rr.txt | ||
for /r %%f in (./*) do curl2 %%f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
env\Scripts\pyinstaller --onefile app.py |