web
This commit is contained in:
46
web/app.py
Normal file
46
web/app.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Set up custom logging
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
||||
# Remove werkzeug logs by setting its logger to a higher level (e.g., ERROR)
|
||||
werkzeug_logger = logging.getLogger('werkzeug')
|
||||
werkzeug_logger.setLevel(logging.ERROR)
|
||||
|
||||
# Log client IP before each request
|
||||
@app.before_request
|
||||
def log_client_ip():
|
||||
# Get client IP address from X-Forwarded-For header or remote_addr
|
||||
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
client_ip = client_ip.split(',')[0] # Get the first IP if it's a forwarded request
|
||||
|
||||
# Override werkzeug's default logging to show client IP in the access log
|
||||
@app.after_request
|
||||
def log_request(response):
|
||||
client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
|
||||
client_ip = client_ip.split(',')[0] # Get the first IP if it's a forwarded request
|
||||
app.logger.info(f"{client_ip} - - [{request.date}] \"{request.method} {request.full_path} {request.environ.get('SERVER_PROTOCOL')}\" {response.status_code}")
|
||||
return response
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
greeting = "Hello, Python!"
|
||||
current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
return render_template('home.html', greeting=greeting, current_time=current_time)
|
||||
|
||||
@app.route('/about')
|
||||
def about():
|
||||
return render_template('about.html')
|
||||
|
||||
# Always redirect back home
|
||||
@app.errorhandler(404)
|
||||
def default_page(e):
|
||||
return redirect(url_for('home'))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True, host="0.0.0.0", port=5005)
|
||||
117
web/static/style.css
Normal file
117
web/static/style.css
Normal file
@@ -0,0 +1,117 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #f4f4f4;
|
||||
}
|
||||
|
||||
header, footer {
|
||||
background-color: #ccc;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 90%;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.contact-info, .buttons {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
background-color: #ddd;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.navbar a {
|
||||
text-decoration: none;
|
||||
color: black;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.about, .map, .service-info, .photos {
|
||||
box-sizing: border-box;
|
||||
padding: 15px;
|
||||
background-color: white;
|
||||
margin: 10px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.about, .map {
|
||||
flex: 2 1 60%;
|
||||
}
|
||||
|
||||
.photos, .directions {
|
||||
flex: 1 1 30%;
|
||||
}
|
||||
|
||||
.map {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.services {
|
||||
margin: 20px 0;
|
||||
padding: 15px;
|
||||
background-color: white;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.service-list {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.service-item {
|
||||
flex: 1 1 200px;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.service-item img {
|
||||
width: 100px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.footer {
|
||||
background-color: #ccc;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
padding: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.footer div {
|
||||
flex: 1 1 100px;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.reviews {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.review-box {
|
||||
width: 150px;
|
||||
height: 80px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
18
web/templates/about.html
Normal file
18
web/templates/about.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>About Us</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>About Our Flask Application</h1>
|
||||
<p>This is a simple Flask application created to demonstrate how to render templates and create routes.</p>
|
||||
<p>Flask is a micro web framework for Python. It is easy to use, lightweight, and flexible for creating web applications.</p>
|
||||
|
||||
<h2>Our Mission</h2>
|
||||
<p>To provide an easy-to-understand tutorial for web development using Flask and Python!</p>
|
||||
|
||||
<p><a href="{{ url_for('home') }}">Back to Home</a></p>
|
||||
</body>
|
||||
</html>
|
||||
91
web/templates/home.html
Normal file
91
web/templates/home.html
Normal file
@@ -0,0 +1,91 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="cs">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Autoservis</title>
|
||||
<link rel="stylesheet" href="{{url_for('static', filename='style.css')}}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1>Autoservis</h1>
|
||||
<div class="contact-info">
|
||||
<span>Kontakt: 123 123 123</span>
|
||||
<span>Otevírací doba: 9-18 hod</span>
|
||||
<span>auto@servis.cz</span>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button>Přihlásit se</button>
|
||||
<button>Objednat se</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="navbar">
|
||||
<a href="#o-nas">O nás</a>
|
||||
<a href="#nabidka-sluzeb">Nabídka služeb</a>
|
||||
<a href="#recenze">Recenze</a>
|
||||
<a href="#kontakt">Kontakt</a>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="content">
|
||||
<div class="about">
|
||||
<h2 id="o-nas">O nás</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla consequat.</p>
|
||||
</div>
|
||||
<div class="photos">
|
||||
<h2>Fotografie autoservisu</h2>
|
||||
</div>
|
||||
<div class="map">
|
||||
<h2>
|
||||
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2607.057050033818!2d16.625835399999996!3d49.19947729999999!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x471294f40ffa3c2b%3A0x6ceee968235c0272!2sCejl%2036%2F64%2C%20602%2000%20Brno-st%C5%99ed!5e0!3m2!1scs!2scz!4v1731501763892!5m2!1scs!2scz" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="directions">
|
||||
<h2>Jak se k nám dostanete?</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="services">
|
||||
<h2 id="nabidka-sluzeb">Nabídka služeb</h2>
|
||||
<div class="service-list">
|
||||
<div class="service-item">
|
||||
<img src="car-icon.png" alt="Car">
|
||||
<p>Oprava osobních vozidel</p>
|
||||
</div>
|
||||
<div class="service-item">
|
||||
<img src="atv-icon.png" alt="ATV">
|
||||
<p>Oprava čtyřkolek</p>
|
||||
</div>
|
||||
<div class="service-item">
|
||||
<img src="scooter-icon.png" alt="Scooter">
|
||||
<p>Oprava skútrů</p>
|
||||
</div>
|
||||
<div class="service-item">
|
||||
<img src="motorcycle-icon.png" alt="Motorcycle">
|
||||
<p>Oprava motorek</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="reviews" id="recenze">
|
||||
<div class="review-box">Recenze 1</div>
|
||||
<div class="review-box">Recenze 2</div>
|
||||
<div class="review-box">Recenze 3</div>
|
||||
<div class="review-box">Recenze 4</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer" id="kontakt">
|
||||
<div>Adresa: Cejl 36, Brno-střed</div>
|
||||
<div>Kontakt: 123 123 123</div>
|
||||
<div>Pobočky: Praha, Brno, Ostrava</div>
|
||||
<div>Služby: Oprava klimatizace, Geometrie kol, Diagnostika</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user