commit e23d6e482d0129253633a2e7bfa95df5f6aec4ff Author: seahi Date: Thu May 22 11:13:21 2025 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eba74f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c275e8 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Simple Python Flask Dockerized Application + +## 运行要求 + +- Python 3.6 及以上版本 +- 默认监听5000端口 + +## 运行方式 + +```bash +# 安装依赖 +pip install -r requirements.txt +# 运行 +python app.py +``` diff --git a/app.py b/app.py new file mode 100644 index 0000000..e72f7ad --- /dev/null +++ b/app.py @@ -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!!

+ 查看美观页面''' + +@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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/templates/beautiful.html b/templates/beautiful.html new file mode 100644 index 0000000..9649a50 --- /dev/null +++ b/templates/beautiful.html @@ -0,0 +1,102 @@ + + + + + + 美观页面 + + + +
+

欢迎来到精美页面

+

这是一个由 Flask 提供的精美网页。我们注重设计与用户体验,希望您喜欢!

+ 返回首页 + +
+
+

简洁设计

+

遵循现代设计理念,注重用户体验与视觉美感。

+
+
+

响应式布局

+

在各种设备上都能呈现最佳显示效果。

+
+
+

精心打造

+

每一个细节都经过精心设计与实现。

+
+
+ +

当前时间: {{ current_time }}

+
+ +