File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed
playground/dolotov/server Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM python:3.10-slim
2+
3+ WORKDIR /app
4+
5+ COPY requirements.txt .
6+
7+ RUN pip install --no-cache-dir -r requirements.txt
8+
9+ COPY . .
10+
11+ CMD ["python" , "app.py" ]
Original file line number Diff line number Diff line change 1+ from flask import Flask , request , jsonify
2+ from pymongo import MongoClient
3+ import os
4+
5+ app = Flask (__name__ )
6+ client = MongoClient ('mongodb://mongo:27017/' )
7+ db = client .screen_recorder
8+
9+ @app .route ('/upload' , methods = ['POST' ])
10+ def upload_file ():
11+ if 'file' not in request .files :
12+ return jsonify ({'error' : 'No file part' }), 400
13+ file = request .files ['file' ]
14+ if file .filename == '' :
15+ return jsonify ({'error' : 'No selected file' }), 400
16+ file_path = os .path .join ('/data' , file .filename )
17+ file .save (file_path )
18+ db .recordings .insert_one ({'filename' : file .filename , 'path' : file_path })
19+ return jsonify ({'success' : True }), 200
20+
21+ if __name__ == '__main__' :
22+ app .run (host = '0.0.0.0' , port = 5000 )
Original file line number Diff line number Diff line change 1+ version : ' 3'
2+ services :
3+ mongo :
4+ image : mongo:5.0
5+ container_name : mongo
6+ ports :
7+ - " 27017:27017"
8+ volumes :
9+ - mongo_data:/data/db
10+
11+ app :
12+ build : .
13+ ports :
14+ - " 5000:5000"
15+ volumes :
16+ - ./data:/data
17+ depends_on :
18+ - mongo
19+
20+ volumes :
21+ mongo_data :
Original file line number Diff line number Diff line change 1+ flask == 3.1.0
2+ flask-pymongo == 3.0.1
You can’t perform that action at this time.
0 commit comments