Technology Sharing

6. Data Visualization - Introduction to the Flask Framework (Crawler and Data Visualization)

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

1. Introduction to Data Visualization

Data visualization is mainly aimed at conveying and communicating information clearly and effectively through graphical means so that more people can understand and use it.
We hope that different platforms can have different display effects, such as PC, Android, and car computers can access it; we hope to unify the different visual effects of data, such as growth-line chart, regional distribution-map, and proportion-pie chart. This effect can be achieved by using web frameworks and chart js frameworks.

Python web framework:
Django, the most famous, large and comprehensive, but there is a certain threshold for beginners
Flask, it is very simple, with only two functions, one is routing forwarding and the other is template rendering

Related frameworks involved in subsequent visualization operations:
FlaskIt is a framework used to build a website
EchartsJS framework for various open source charts
WordcloudThe word cloud displays the frequency of words in the form of graphics and images.

2,flask

(1) Create a flask project

How to quickly create a project with the flask framework in pycharm

Click file, new project in the upper left corner

insert image description here

insert image description here

insert image description here

insert image description here

from flask import Flask         #从flask包中引入Flask模块

app = Flask(__name__)           #通过默认的名字,初始化了全局对象


#此处是flask完成定制的内容
#路由解析,通过用户访问的路径匹配相应的函数
@app.route('/')
def hello_world():
    return '你好!'           #注意默认没有开启debug模式(程序发布状态),所以此处的修改不会实时显示到服务器,可以重启服务器


if __name__ == '__main__':
    app.run()                   #调用对象,run方法就是服务器监听端口