Files
simplefileupload-server/src/app.py

29 lines
855 B
Python
Raw Normal View History

2024-10-07 23:16:42 -04:00
import os
import uuid
from flask import Flask, request, jsonify, send_from_directory
from werkzeug.utils import secure_filename
import requests
import utils.mLogger as log
from controllers.file_controller import upload_file, download_file, delete_file
2025-04-14 20:47:26 -04:00
from views import views
2024-10-07 23:16:42 -04:00
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'tmp/uploads'
if not os.path.exists(app.config['UPLOAD_FOLDER']):
os.makedirs(app.config['UPLOAD_FOLDER'])
# Route for file uploads
2025-04-14 20:47:26 -04:00
app.route('/upload', methods=['POST'])(upload_file)
2024-10-07 23:16:42 -04:00
2025-04-14 20:47:26 -04:00
# Route for downloading the file
app.route('/download/<code>', methods=['GET'])(download_file)
2024-10-07 23:16:42 -04:00
# Route for deleting the file
app.route('/delete/<code>', methods=['DELETE'])(delete_file)
2025-04-14 20:47:26 -04:00
app.register_blueprint(views)
2024-10-07 23:16:42 -04:00
if __name__ == '__main__':
log.i("Running flask in debug...")
app.run(debug=True, host="0.0.0.0", port=7777)