apache 在Python中将uid打印到屏幕/浏览器

x3naxklr  于 2023-10-23  发布在  Apache
关注(0)|答案(1)|浏览(135)

我目前正在测试mod_wsgi,并尝试在浏览器中打印我的uid。

  1. import os
  2. uid = os.getuid()
  3. print("uid being used:", uid)
  4. def application(environ, start_response):
  5. status = '200 OK'
  6. output = b'Hello World!'
  7. response_headers = [('Content-type', 'text/plain'),
  8. ('Content-Length', str(len(output)))]
  9. start_response(status, response_headers)
  10. return [output]

预期的结果是,我会得到我的uid打印在屏幕上。所以我知道什么用户Mod_wsgi脚本正在运行..但我目前只将Hello World打印到屏幕

xeufq47z

xeufq47z1#

在discord上找到了答案,因为其他人可能会发现它有帮助

  1. import os
  2. def application(environ, start_response):
  3. status = '200 OK'
  4. output = f"Hello World! {os.getuid()}".encode()
  5. response_headers = [('Content-type', 'text/plain'),
  6. ('Content-Length', str(len(output)))]
  7. start_response(status, response_headers)
  8. return [output]

相关问题