简体   繁体   English

如何在 EC2 ubuntu flask 应用程序或命令提示符中获取 windows 登录用户名

[英]How to get windows login username in EC2 ubuntu flask app or command prompt

I need to get the windows login username in my Flask app which is deployed in AWS EC2 instance.我需要在部署在 AWS EC2 实例中的 Flask 应用程序中获取 windows 登录用户名。

Hmm, I'm assuming your Flask application is running on a Windows EC2 instance and you want to get the login username on the local instance that it is running on?嗯,我假设您的 Flask 应用程序正在 Windows EC2 实例上运行,并且您想在运行它的本地实例上获取登录用户名? In that case, it really should be as simple as retrieving it from the environment variables, for example using this python snippet:在这种情况下,它真的应该像从环境变量中检索它一样简单,例如使用这个 python 片段:

import os

USER = os.getenv('USERNAME')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM