Skip to content

Commit

Permalink
Add fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Do1otov authored Feb 24, 2025
1 parent 93d9c7d commit a941092
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
17 changes: 13 additions & 4 deletions playground/dolotov/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
import os

app = Flask(__name__)

client = MongoClient('mongodb://mongo:27017/')
db = client.screen_recorder

@app.route('/upload', methods=['POST'])
def upload_file():
if 'file' not in request.files:
return jsonify({'error': 'No file part'}), 400

file = request.files['file']
if file.filename == '':
return jsonify({'error': 'No selected file'}), 400
file_path = os.path.join('/data', file.filename)
file.save(file_path)
db.recordings.insert_one({'filename': file.filename, 'path': file_path})
return jsonify({'success': True}), 200

try:
file_path = os.path.join('/data', file.filename)
file.save(file_path)

db.recordings.insert_one({'filename': file.filename, 'path': file_path})

return jsonify({'success': True}), 200
except Exception as e:
print(f"Ошибка при сохранении файла или записи в базу данных: {e}")
return jsonify({'error': 'Internal server error'}), 500

if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
14 changes: 10 additions & 4 deletions playground/dolotov/server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3'
services:
mongo:
image: mongo:5.0
image: mongo:8.0
container_name: mongo
ports:
- "27017:27017"
volumes:
- mongo_data:/data/db
networks:
- backend

app:
build: .
Expand All @@ -16,6 +16,12 @@ services:
- ./data:/data
depends_on:
- mongo
networks:
- backend

volumes:
mongo_data:
mongo_data:

networks:
backend:
driver: bridge

0 comments on commit a941092

Please sign in to comment.