web.py – 静态Static Files

来源:互联网 发布:一机多图软件 编辑:程序博客网 时间:2024/05/17 06:08

准备文件

建立目录static,并把文件存入static中.

实例代码:

#!/usr/bin/env python

# -*- coding: UTF-8 -*-

 

import web

 

page="""

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title>图片插入html 在线演示</title>

</head>

<body>

 

<p>图片 240*400</p>

<p>

<img src="static/fuli.jpg"width="240" height="400" />

</p>

</body>

</html>

"""

urls = ("/.*", "hello")

app = web.application(urls, globals())

 

class hello:

    def GET(self):

        return page

 

if __name__ == "__main__":

app.run()

 

访问效果:



0 0
原创粉丝点击