Skip to content

Commit f984b98

Browse files
authored
Add server
1 parent 1e83362 commit f984b98

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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"]

playground/dolotov/server/app.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flask==3.1.0
2+
flask-pymongo==3.0.1

0 commit comments

Comments
 (0)