commit
da905675e7
6 changed files with 107 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||
from flask import Flask, jsonify |
|||
|
|||
app = Flask(__name__, static_folder="public", static_url_path="/static") |
|||
|
|||
|
|||
# 根路径返回 index.html |
|||
@app.route("/") |
|||
def serve_index(): |
|||
return app.send_static_file("index.html") |
|||
|
|||
|
|||
# API 子路径,提供数据 |
|||
@app.route("/api/data") |
|||
def api_data(): |
|||
return jsonify({ |
|||
"message": "Welcome to Beijing Wildlife Park", |
|||
"data": [ |
|||
{"name": "Panda", "description": "Giant panda native to China"}, |
|||
{"name": "Giraffe", "description": "The tallest land animal"}, |
|||
{"name": "Elephant", "description": "The largest land animal"} |
|||
] |
|||
}) |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
app.run(debug=True, port=80) |
@ -0,0 +1,18 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Beijing Wildlife Park</title> |
|||
<link rel="stylesheet" href="/static/style.css"> |
|||
</head> |
|||
<body> |
|||
<h1>Beijing Wildlife Park</h1> |
|||
<img src="/static/beijing-wildlife.jpg" alt="Wildlife in Beijing"> |
|||
<p>Welcome to Beijing Wildlife Park, home to a variety of animals.</p> |
|||
<h2>Animals</h2> |
|||
<ul id="animal-list"> |
|||
<!-- Animal list will be dynamically inserted here --> |
|||
</ul> |
|||
<script src="/static/script.js"></script> |
|||
</body> |
|||
</html> |
After Width: | Height: | Size: 3.9 MiB |
@ -0,0 +1,18 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Beijing Wildlife Park</title> |
|||
<link rel="stylesheet" href="/static/style.css"> |
|||
</head> |
|||
<body> |
|||
<h1>Beijing Wildlife Park</h1> |
|||
<img src="/static/beijing-wildlife.jpg" alt="Wildlife in Beijing"> |
|||
<p>Welcome to Beijing Wildlife Park, home to a variety of animals.</p> |
|||
<h2>Animals</h2> |
|||
<ul id="animal-list"> |
|||
<!-- Animal list will be dynamically inserted here --> |
|||
</ul> |
|||
<script src="/static/script.js"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,14 @@ |
|||
document.addEventListener('DOMContentLoaded', function() { |
|||
const animals = [ |
|||
{ name: "Panda", description: "Giant panda native to China" }, |
|||
{ name: "Giraffe", description: "The tallest land animal" }, |
|||
{ name: "Elephant", description: "The largest land animal" } |
|||
]; |
|||
|
|||
const animalListElement = document.getElementById('animal-list'); |
|||
animals.forEach(animal => { |
|||
const li = document.createElement('li'); |
|||
li.textContent = `${animal.name} - ${animal.description}`; |
|||
animalList.appendChild(li); |
|||
}); |
|||
}); |
@ -0,0 +1,31 @@ |
|||
body { |
|||
font-family: Arial, sans-serif; |
|||
background-color: #f8f4f9; |
|||
color: #333; |
|||
margin: 0; |
|||
padding: 20px; |
|||
} |
|||
|
|||
h1 { |
|||
color: #d4ea; |
|||
text-align: center; |
|||
} |
|||
|
|||
img { |
|||
max-width: 100%; |
|||
height: auto; |
|||
} |
|||
|
|||
a { |
|||
color: #d4ea; |
|||
text-decoration: none; |
|||
} |
|||
|
|||
a:hover { |
|||
text-decoration: underline; |
|||
} |
|||
|
|||
#animal-list li { |
|||
list-style-type: none; |
|||
margin-bottom: 10px; |
|||
} |
Loading…
Reference in new issue