A super simple python web program

  • 2020-04-02 14:06:12
  • OfStack

In the MAC/LINUX environment, execute the vi hello.py command and enter the following code


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()

Execution of python hello.py 8080 appears  

(link: http://0.0.0.0:8080/)
Then access "(link: http://localhost:8080/Service/Match)" address, return the result


Hello,world!


The terminal result is:


127.0.0.1:49400 - - [15/Aug/2014 17:57:26] "HTTP/1.1 GET /Service/Match" - 200 O


Related articles: