

from flask import Flask, render_template
app = Flask(__name__)
# 模拟按摩店的信息(中文)
massage_shop = {
'name': '放松天地按摩店',
'description': '欢迎来到放松天地按摩店,我们提供舒缓身心的宁静体验。无论您寻求疗愈按摩还是只是想放松一下,我们的专业治疗师都会满足您的需求。',
'services': [
{'name': '瑞典按摩', 'description': '经典按摩,有助于放松和缓解肌肉紧张。'},
{'name': '深层组织按摩', 'description': '针对深层肌肉和结缔组织,适合慢性肌肉问题。'},
{'name': '热石按摩', 'description': '利用加热石头放松肌肉,促进血液循环,平静神经系统。'}
],
'contact': {
'phone': '+1234567890',
'email': 'info@relaxationhaven.com',
'address': '54321, 禅静城, 宁静路123号'
}
}
@app.route('/')
# #在当前目录下新建一个名为templates的文件夹,将index.html放在这个文件夹下
def index():
return render_template('index.html', shop=massage_shop)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
##index.html文件代码
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Remote Movie Player</title>
</head>
<body>
<h1>Welcome to the Remote Movie Player!</h1>
<p>Click below to play the movie:</p>
<a href="/play_movie" target="_blank">Play Movie</a>
</body>
</html> -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ shop.name }}</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
padding: 20px;
}
.container {
max-width: 800px;
margin: auto;
}
.service {
margin-bottom: 20px;
padding: 10px;
background-color: #f0f0f0;
}
</style>
</head>
<body>
<div class="container">
<h1>{{ shop.name }}</h1>
<p>{{ shop.description }}</p>
<h2>我们的服务</h2>
{% for service in shop.services %}
<div class="service">
<h3>{{ service.name }}</h3>
<p>{{ service.description }}</p>
</div>
{% endfor %}
<h2>联系我们</h2>
<p>电话:{{ shop.contact.phone }}</p>
<p>邮箱:<a href="mailto:{{ shop.contact.email }}">{{ shop.contact.email }}</a></p>
<p>地址:{{ shop.contact.address }}</p>
</div>
</body>
</html>