美文网首页
python3 flask

python3 flask

作者: 一剑仙人跪_ | 来源:发表于2021-05-08 10:34 被阅读0次

参考文章 https://blog.csdn.net/yang9520/article/details/79740374
Flask是由python实现的一个web微框架,让我们可以使用Python语言快速实现一个网站或Web服务。

安装flask

pip3 install flask

创建一个hello.py文件

[root@xunjian flask_uwsgi]# cat hello.py 
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_flask():
    return 'Hello Flask!!'

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=5000)

运行hello.py

[root@xunjian flask_uwsgi]# python3 hello.py 
 * Serving Flask app "hello" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

浏览器访问

image.png

相关文章

网友评论

      本文标题:python3 flask

      本文链接:https://www.haomeiwen.com/subject/umbnrltx.html