Browse Source

first commit

master
phamduchongan93 8 months ago
commit
6a21feef0c
5 changed files with 140 additions and 0 deletions
  1. +27
    -0
      Dockerfile
  2. +20
    -0
      app.py
  3. BIN
      qr_code.png
  4. BIN
      static/qr_code.png
  5. +93
    -0
      templates/index.html

+ 27
- 0
Dockerfile View File

@ -0,0 +1,27 @@
# Use the official Python image as base
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set the working directory in the container
WORKDIR /app
# Copy the requirements file into the container
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire application into the container
COPY . .
# Create a volume for static files
VOLUME /app/static
# Expose the port the app runs on
EXPOSE 5000
# Command to run the application
CMD ["python", "app.py"]

+ 20
- 0
app.py View File

@ -0,0 +1,20 @@
#!/bin/python3
from flask import Flask, render_template
import qrcode
import os
app = Flask(__name__, template_folder="templates")
@app.route('/')
def index():
# Generate QR code
qr = qrcode.QRCode(version=1, box_size=10, border=5)
qr.add_data("localhost") # You can replace this URL with any link you want
qr.make(fit=True)
qr_img = qr.make_image(fill_color="black", back_color="white")
qr_img = qr.make_image(fill_color="black", back_color="white")
qr_img.save("/home/anpham/Projects/virtual-bussiness-card/static/qr_code.png") # Save QR code image
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)

BIN
qr_code.png View File

Before After
Width: 390  |  Height: 390  |  Size: 680 B

BIN
static/qr_code.png View File

Before After
Width: 310  |  Height: 310  |  Size: 431 B

+ 93
- 0
templates/index.html View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Virtual Business Card</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
.card {
width: 300px;
margin: 50px auto;
background-color: #fff;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 8px;
padding: 20px;
}
.card h1, .card h2, .card p {
margin: 0;
}
.card h1 {
color: #333;
}
.card h2 {
color: #666;
font-size: 18px;
margin-bottom: 10px;
}
.card p {
color: #777;
font-size: 16px;
}
.qr-code {
margin-top: 20px;
text-align: center;
}
.social-buttons {
margin-top: 20px;
text-align: center;
}
.social-buttons a {
display: inline-block;
margin-right: 10px;
}
.social-buttons a img {
width: 40px;
height: 40px;
border-radius: 50%;
}
@media only screen and (max-width: 600px) {
.social-buttons a img {
width: 30px;
height: 30px;
}
}
@media only screen and (max-width: 400px) {
.social-buttons {
margin-top: 10px;
}
.social-buttons a img {
width: 25px;
height: 25px;
}
}
</style>
</head>
<body>
<div class="card">
<h1>John Doe</h1>
<h2>CEO & Founder</h2>
<p>Acme Corporation</p>
<p>Email: [email protected]</p>
<p>Phone: +1234567890</p>
<div class="qr-code">
<img src="{{ url_for('static', filename='qr_code.png') }}" alt="QR Code">
</div>
<div class="social-buttons">
<a href="https://www.instagram.com/your_instagram_username" target="_blank"><img src="instagram_icon.png" alt="Instagram"></a>
<a href="https://www.facebook.com/your_facebook_username" target="_blank"><img src="facebook_icon.png" alt="Facebook"></a>
<a href="https://www.yourwebsite.com" target="_blank"><img src="website_icon.png" alt="Personal Website"></a>
</div>
</div>
</body>
</html>

Loading…
Cancel
Save