first commit
This commit is contained in:
commit
e23d6e482d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
venv/
|
15
README.md
Normal file
15
README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Simple Python Flask Dockerized Application
|
||||||
|
|
||||||
|
## 运行要求
|
||||||
|
|
||||||
|
- Python 3.6 及以上版本
|
||||||
|
- 默认监听5000端口
|
||||||
|
|
||||||
|
## 运行方式
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 安装依赖
|
||||||
|
pip install -r requirements.txt
|
||||||
|
# 运行
|
||||||
|
python app.py
|
||||||
|
```
|
20
app.py
Normal file
20
app.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from flask import Flask, render_template
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def hello():
|
||||||
|
return '''Flask inside Docker!!<br><br>
|
||||||
|
<a href="/beautiful" style="display: inline-block; background-color: #3498db; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; font-family: Arial, sans-serif;">查看美观页面</a>'''
|
||||||
|
|
||||||
|
@app.route("/beautiful")
|
||||||
|
def beautiful_page():
|
||||||
|
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
return render_template("beautiful.html", current_time=current_time)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
port = int(os.environ.get("PORT", 5000))
|
||||||
|
app.run(debug=True,host='0.0.0.0',port=port)
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
flask
|
102
templates/beautiful.html
Normal file
102
templates/beautiful.html
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>美观页面</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
background: linear-gradient(120deg, #a1c4fd, #c2e9fb);
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
background-color: rgba(255, 255, 255, 0.9);
|
||||||
|
border-radius: 15px;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
||||||
|
padding: 40px;
|
||||||
|
max-width: 800px;
|
||||||
|
text-align: center;
|
||||||
|
animation: fadeIn 1s;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #3498db;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
background-color: #3498db;
|
||||||
|
color: white;
|
||||||
|
padding: 12px 24px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 30px;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.btn:hover {
|
||||||
|
background-color: #2980b9;
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.features {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
margin-top: 40px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
.feature {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 200px;
|
||||||
|
margin: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: rgba(255, 255, 255, 0.7);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
.feature h3 {
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateY(20px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>欢迎来到精美页面</h1>
|
||||||
|
<p>这是一个由 Flask 提供的精美网页。我们注重设计与用户体验,希望您喜欢!</p>
|
||||||
|
<a href="/" class="btn">返回首页</a>
|
||||||
|
|
||||||
|
<div class="features">
|
||||||
|
<div class="feature">
|
||||||
|
<h3>简洁设计</h3>
|
||||||
|
<p>遵循现代设计理念,注重用户体验与视觉美感。</p>
|
||||||
|
</div>
|
||||||
|
<div class="feature">
|
||||||
|
<h3>响应式布局</h3>
|
||||||
|
<p>在各种设备上都能呈现最佳显示效果。</p>
|
||||||
|
</div>
|
||||||
|
<div class="feature">
|
||||||
|
<h3>精心打造</h3>
|
||||||
|
<p>每一个细节都经过精心设计与实现。</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="margin-top: 40px;">当前时间: {{ current_time }}</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
x
Reference in New Issue
Block a user