周翔 发表于 2018-8-16 08:07:08

Python Web 框架 Sanic Linux平台安装

  1.操作系统
  CentOS 7.2 X64
  2.安装系统包
  gcc-c++
  zlib-devel
  openssl-devel
  3.update python 3.5
  1).安装Python
  Python-3.5.2.tgz
  ./configure
  make
  make install
  2).软连接新版本
  cd /usr/bin
  rm python
  ln -s /usr/local/bin/python3 /usr/bin/python
  4.安装Python包
  1).setuptools-30.3.0.tar.gz
  2).uvloop-0.6.7.tar.gz
  3).multidict-2.1.4.tar.gz
  4).aiofiles-0.3.0.tar.gz
  5).ujson-1.35.tar.gz
  6).httptools-0.0.9.tar.gz
  7).Sanic-0.1.8.tar.gz
  5.测试安装
  root用户,/home/目录新建helloword.py
  1). server程序
  # vi helloword.py
  from sanic import Sanic
  from sanic.response import json
  app = Sanic()
  @app.route("/")
  async def test(request):
  return json({"hello": "world"})
  app.run(host="0.0.0.0", port=8000)
  2).运行访问
  # python helloword.py
  2016-12-09 23:21:22,333: INFO: Goin' Fast @ http://0.0.0.0:8000
  客户端访问
  http://serverip:8000/
  出现
  {"hello": "world"}
页: [1]
查看完整版本: Python Web 框架 Sanic Linux平台安装