I have a python script with flask API. I am running the code in command line python scriptname.py
and making an POST call and it works.
But in realtime how to enable this set up on windows server, so that script is running and available anytime for third-party to make HTTP post. Any pointers please.
class Impersonate:
def __init__(self,login,password):
self.domain='<domain>'
self.login=login
self.password=password
def logon(self):
self.handel=win32security.LogonUser(self.login,self.domain,self.password,win32con.LOGON32_LOGON_INTERACTIVE,win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(self.handel)
def logoff(self):
win32security.RevertToSelf() #terminates impersonation
self.handel.Close() #guarantees cleanup
a=Impersonate('testuser','password]')
try:
a.logon() #become the user
print(a.login)
a.logoff() #return to normal
except:
pass
app = Flask(__name__)
api = Api(app)
class Hellow(Resource):
def post(self):
path = os.path.join(parentdir, dirname)
try:
os.makedirs(path)
resp = Response('{} successfully created.)
api.add_resource(Hellow, '/test')
if __name__ == "__main__":
app.run(port=5000, host="<hostname>" use_reloader=True)