最近在使用Pyhon写一些爬虫的时候,因为是临时作为服务使用的,就选了Flask
一个轻量级的 Python web 框架,然后前端使用vue
编写了一个单页。
这是项目结构:
就一个home页面,引入的自己本地的Vue.js文件,app.py是项目的启动文件。
先看Python
代码:总的来说,这段代码定义了一个非常简单的 Flask web
应用,当用户访问网站的主页时,它会返回名为 ‘home.html’ 的模板文件的内容。
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html');
if __name__ == '__main__':
app.run(debug=True)
home.html文件代码:
<!DOCTYPE html