commit a8d35510c27ceccf8ffc93a7e679442bfadbcb94 Author: Maxim Romanko Date: Thu Aug 8 17:44:30 2024 +0300 [INIT] diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f5e96db --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a532efc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12.4 + +MAINTAINER maxim Romanko (vadzik) + +ENV TZ="Europe/Moscow" + +# set a directory for the app +WORKDIR /usr/src/app + +# copy all the files to the container +COPY main.py . +COPY req.txt . +RUN mkdir ./images + +# install app-specific dependencies +RUN pip install --no-cache-dir -r req.txt + +# app command +CMD ["python", "-u", "./main.py"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..846c3de --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +version: '3.9' + +services: + + telegram_bot_docker_tmpl: + container_name: QRCodeAPI + image: qr_code_api + + build: . + + restart: always \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..aa2a6a2 --- /dev/null +++ b/main.py @@ -0,0 +1,18 @@ +from flask import Flask, request +import qrcode + +app = Flask(__name__) + +@app.route('/qr_code', methods=['POST']) +def generate_qr_code(): + data = request.form.get('data') + qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4) + qr.add_data(data) + qr.make(fit=True) + qr_img = qr.make_image(fill_color="black", back_color="white") + qr_img.save('qr_code.png') + return 'QR code generated!' + + +if __name__ == '__main__': + app.run() \ No newline at end of file diff --git a/req.txt b/req.txt new file mode 100644 index 0000000..1512ae4 --- /dev/null +++ b/req.txt @@ -0,0 +1,2 @@ +flask +qrcode \ No newline at end of file