Ubuntu18.04系統(tǒng)如何安裝sanic
Sanic 是一個(gè)類Flask 的基于Python3.5 的web框架,它編寫的代碼速度特別快。那么在ubuntu18.04中如何安裝sanic呢?本文給出詳細(xì)說明。
1.首先確認(rèn)安裝了python3
說明:一般linux系統(tǒng)默認(rèn)都有安裝python環(huán)境,包括python2和python3,在命令行中python默認(rèn)指的是python2。python2已經(jīng)接近淘汰,但由于linux系統(tǒng)環(huán)境中還有大量基于python2的軟件,因此在linux系統(tǒng)中還保留著python2。目前推薦使用python3。
2.更新軟件列表
sudo apt-get update
3.安裝python3-pip
sudo apt-get install python3-pip
4.安裝flask
sudo pip3 install sanic
5.創(chuàng)建一個(gè)sanic程序
vi hello.py
在其中寫入
from sanic import Sanic from sanic.response import text app = Sanic(__name__) @app.route('/') async def hello_world(request): return text('hello,world') app.run(host="0.0.0.0", port=8000, debug=True)
保存退出
6.運(yùn)行hello.py
python3 hello.py
7.測試
在瀏覽器打開主機(jī)IP:8000
安裝成功
版權(quán)保護(hù): 本文「Ubuntu18.04系統(tǒng)如何安裝sanic」由 云主機(jī)配置專家 原創(chuàng),轉(zhuǎn)載請保留鏈接: http://www.iqcg.cn/docs/system/791.html