This commit is contained in:
Maxim Romanko 2024-08-08 17:44:30 +03:00
commit a8d35510c2
5 changed files with 51 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
venv

19
Dockerfile Normal file
View File

@ -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"]

11
docker-compose.yaml Normal file
View File

@ -0,0 +1,11 @@
version: '3.9'
services:
telegram_bot_docker_tmpl:
container_name: QRCodeAPI
image: qr_code_api
build: .
restart: always

18
main.py Normal file
View File

@ -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()

2
req.txt Normal file
View File

@ -0,0 +1,2 @@
flask
qrcode