我有简单的python服务,工作正常。我想在IIS上部署它。可能吗?如果是,那怎么样? 以下是我的服务代码。 TestService.py
import web
import xml.etree.ElementTree as ET
tree = ET.parse('user_data.xml')
root = tree.getroot()
urls = (
'/users', 'list_users',
'/users/(.*)', 'get_user'
)
app = web.application(urls, globals())
class list_users:
def GET(self):
output = 'users:[';
for child in root:
print 'child', child.tag, child.attrib
output += str(child.attrib) + ','
output += ']';
return output
class get_user:
def GET(self, user):
for child in root:
if child.attrib['id'] == user:
return str(child.attrib)
if __name__ == "__main__":
app.run()
和user_data.xml
<users>
<user id="10" name="Rocky" age="38"/>
<user id="20" name="Steve" age="50"/>
<user id="30" name="Melinda" age="38"/>
</users>
我已阅读此帖Python on IIS: how?,但它不适用于我。