[INIT]
This commit is contained in:
commit
a8d35510c2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
venv
|
||||
19
Dockerfile
Normal file
19
Dockerfile
Normal 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
11
docker-compose.yaml
Normal 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
18
main.py
Normal 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()
|
||||
Loading…
x
Reference in New Issue
Block a user