Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Python Project Scripts
  • Loading branch information
“gyyzzz” committed Jul 2, 2025
commit 76abbe4bba75902e6d230cf92994ce607cbc45b0
3 changes: 3 additions & 0 deletions FLASK PROJECTS/Anniversary time/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Anniversary Timing

Simple timing page implemented using flask
17 changes: 17 additions & 0 deletions FLASK PROJECTS/Anniversary time/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from flask import Flask, render_template
from datetime import datetime

app = Flask(__name__)

# 在此定义纪念日日期
anniversary_date = datetime(2024, 6, 16)

@app.route('/')
def index():
current_date = datetime.now()
delta = current_date - anniversary_date
days_passed = delta.days
return render_template('index.html', days_passed=days_passed, anniversary_date=anniversary_date.strftime("%Y-%m-%d %H:%M:%S"))

if __name__ == '__main__':
app.run(debug=False)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions FLASK PROJECTS/Anniversary time/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background: url('background.jpg') no-repeat center center fixed;
background-size: cover;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}

h1 {
font-size: 3em;
}

.time {
font-size: 2em;
margin-top: 20px;
}

.time span {
font-weight: bold;
}
39 changes: 39 additions & 0 deletions FLASK PROJECTS/Anniversary time/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anniversary</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<script>
function updateTimer() {
const anniversaryDate = new Date("{{ anniversary_date }}");
const currentDate = new Date();
const timeDiff = currentDate - anniversaryDate;

const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);

document.getElementById("days").innerText = days;
document.getElementById("hours").innerText = hours;
document.getElementById("minutes").innerText = minutes;
document.getElementById("seconds").innerText = seconds;
}

setInterval(updateTimer, 1000);
</script>
</head>
<body onload="updateTimer()">
<div class="container">
<h1>It has passed the xx anniversary</h1>
<div class="time">
<span id="days">0</span> 天
<span id="hours">0</span> 小时
<span id="minutes">0</span> 分钟
<span id="seconds">0</span> 秒
</div>
</div>
</body>
</html>