【Python】【Bobo】,,我的Mac环境,py


我的Mac环境,python3.5

1. 安装bobo : >>> pip3 install bobo

2. 配置环境变量:

$: vi ~/.bash_profile

加一行:alias bobo = "地址" (我刚install完bobo后,在python3.5的bin里多了个bobo的启动文件,这个地址就是这个启动文件的地址)

退出vi

$: source ~/.bash_profile

3. 创建使用bobo的方法在某个py文件 ,文件内容

import bobo
@bobo.query(‘/‘)
def hello(person):
return ‘Hello %s‘ % person

4. $: bobo -f py文件地址/py文件名字。

这样就启动了bobo开发服务器

5. 进入浏览器,输入:localhost:8080

6. 浏览器显示“Missing form variable person”

7. 另开一个终端输入curl -i http://localhost:8080/,打印如下

HTTP/1.0 403 Forbidden

Date: Fri, 06 Oct 2017 06:20:35 GMT

Server: WSGIServer/0.2 CPython/3.5.3

Content-Type: text/html; charset=UTF-8

Content-Length: 103

<html>

<head><title>Missing parameter</title></head>

<body>Missing form variable person</body>

</html>

8 另外开一个终端,输入:curl -i http://localhost:8080/?person=jim

终端打印:

HTTP/1.0 200 OK

Date: Fri, 06 Oct 2017 06:21:14 GMT

Server: WSGIServer/0.2 CPython/3.5.3

Content-Type: text/html; charset=UTF-8

Content-Length: 9

浏览器输入localhost:8080/?person=jim,浏览器显示:

Hello jim




【Python】【Bobo】

评论关闭