📄 lrwpskel.py
字号:
"""A small long-running web process for Xitami.
Takes a run-time argument and returns this plus a call count
each time it is called, terminating after ten calls."""
import sys
myname = sys.argv[1]
callcount = 0
import lrwplib
#
# One-time LRWP startup logic: connect to local Xitami
# to serve a fixed number of application "lrtest" requests
#
try:
lrwp = lrwplib.LRWP("lrtest", '127.0.0.1', 81, '')
lrwp.connect()
print "Connected to Xitami"
sys.stdout.flush()
except:
raise # comment this out when connection works
sys.exit("Could not start long-running web process.")
while 1:
#
# Per-request code
#
request = lrwp.acceptRequest() # blocks until server has work
query = request.getFieldStorage() # retrieve task as a CGI call
callcount += 1
#
# Page generation logic
#
#request.out.write("""Content-Type: text/html\n\n""")
request.out.write("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>LONG-RUNNING WEB PROCESS %s</title>
</head>
<body>
""" % myname)
request.out.write("""<H1>Process %s, call %d</H1>""" % (myname, callcount))
request.out.write("""
</body>
</html>
""")
request.finish()
if callcount == 10:
break
#
# LRWP Process termination
#
lrwp.close()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -