一个超级简单的python web程序

  • 2023-04-07 21:14:09

在mac/linux环境下,执行vi hello.py命令,并输入以下代码

import web
import sys
 
urls = ("/service/hello","hello")
app = web.application(urls,globals())
 
class hello:
    def get(self):
        return 'hello,world!';
if __name__=="__main__":
    app.run()

执行python hello.py 8080出现 


然后访问"http://localhost:8080/service/match"地址,返回结果为

hello,world!


终端的结果为:

127.0.0.1:49400 - - [15/aug/2014 17:57:26] "http/1.1 get /service/match" - 200 o

猜你喜欢