网页显示很奇怪...

来源:2-2 web.py的demo

微sun

2018-09-06 09:21

这个是1.html的内容:

<html>

<head>

<title>Hello</title>

<script>

function show_text(id, text){

document.getElementById(id).innerHTML = text;

}

function show_color(id, color){

document.getElementById(id).style.color = color;

}

</script>

<style>

#ll {width: 200px; font-size:40px;}

</style>

</head>

<body>

<label id="ll">test</label>

<div>

<a href="javascript:void(0);" onclick='javascript:show_text("ll", "My First JavaScript");'>My First JavaScript</a><br>

<a href="javascript:void(0);" onclick='javascript:show_text("ll", "Hello python")'>Hello python</a><br>

<a href="javascript:void(0);" onclick='javascript:show_color("ll", "#f00")'>red</a><br>

<a href="javascript:void(0);" onclick='javascript:show_color("ll", "#0f0")'>green</a><br>

</div>

</body>

</html>


import web


urls = (

'/(.*)', 'hello'

)


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


class hello:

def GET(self, name):

return open(r'1.html', 'r').read()

if __name__ == "__main__":

app.run()

这个是hello.py的内容:

import web

        

urls = (

    '/(.*)', 'hello'

)

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


class hello:        

    def GET(self, name):

        return open(r'1.html' , 'r').read()


if __name__ == "__main__":

    app.run()

然后输入http://127.0.0.1:8080 访问的时候,就是这样的...

https://img.mukewang.com/5b9080e40001076618530931.jpg

刚开始学习,求大神指点

写回答 关注

1回答

  • 微sun
    2018-09-06 09:31:37

    改好了~

python-web.py开发入门

web.py开发入门入门教程,讲解一个你最快能学会的web开发的框架

58639 学习 · 106 问题

查看课程

相似问题