Files
python-flask/project11/02.[任务书]开发搜索引擎.md
2025-09-11 16:59:33 +08:00

48 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 开发搜索引擎
## 需求
- 小明同学看着搜索引擎感觉功能很神奇,想要花亿点点时间,自己开发一个,你能帮帮他么?
- 利用flask作为后端开发一个和百度一样体验的搜索引擎
- 目前已有前端代码https://www.123865.com/s/BKNfTd-QKXKA提取码:6666
## 参考代码
- 此程序涉及到前后端多个代码文件
- 项目压缩包下载地址https://www.123865.com/s/BKNfTd-EKXKA提取码:6666
```python
import flask
from flask import request, redirect
app = flask.Flask(__name__, static_folder='static')
@app.route('/')
def index():
return flask.render_template('index.html')
@app.route("/search/", methods=['POST'])
def search():
# 从post中获取wd的提交内容
wd = request.form.get('wd')
# 重定向到构造好的百度搜索连接
return redirect(f"https://www.baidu.com/s?wd={wd}")
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=8088)
```
<video src="../video/project11/效果展示.mp4" width="100%" controls>
您的浏览器不支持 Video 标签。
</video>
><span style="color: red; background: yellow; padding: 2px 5px; font-size: 22px;">作业11.1提交的内容</span>
>
>- 理解程序的运行逻辑
>- 程序运行成功的截图,单独发送给组长