Yes. I created a python service application.
Connecting to log stream...
2021-01-13T12:27:40 Welcome, you are now connected to log-streaming service.
Starting Log Tail -n 10 of existing logs ----
/home/LogFiles/__lastCheckTime.txt (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/\_\_lastCheckTime.txt)
01/13/2021 12:26:39
/home/LogFiles/kudu/trace/619de34c3c90-3e6358b5-4eb2-4c01-81a9-f333e1ec7563.txt (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/619de34c3c90-3e6358b5-4eb2-4c01-81a9-f333e1ec7563.txt)
2021-01-13T12:16:07 Startup Request, url: /api/zipdeploy?isAsync=true&author=VS%20Code, method: POST, type: request, pid: 178,1,5, ScmType: None
/home/LogFiles/kudu/trace/b152ada318c8-0cfa98a4-3907-4190-985e-5ababcfdc3c3.txt (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/b152ada318c8-0cfa98a4-3907-4190-985e-5ababcfdc3c3.txt)
2021-01-13T12:25:37 Startup Request, url: /api/zipdeploy?isAsync=true&author=VS%20Code, method: POST, type: request, pid: 139,1,4, ScmType: None
/home/LogFiles/kudu/trace/b152ada318c8-a53ab6b2-8c16-4001-8a90-0d0035d5bdb3.txt (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/kudu/trace/b152ada318c8-a53ab6b2-8c16-4001-8a90-0d0035d5bdb3.txt)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Kudu.Services.Web.Tracing.TraceMiddleware.Invoke(HttpContext context) in /tmp/KuduLite/Kudu.Services.Web/Tracing/TraceMiddleware.cs:line 55
2021-01-13T12:26:55 Outgoing response, type: response, statusCode: 500, statusText: InternalServerError
/home/LogFiles/2021_01_13_lw0sdlwk000307_default_docker.log (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/2021_01_13_lw0sdlwk000307_default_docker.log)
2021-01-13T12:26:52.122424011Z File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-01-13T12:26:52.122428111Z File "/tmp/8d8b7be59131faf/app.py", line 4, in <module>
2021-01-13T12:26:52.122432311Z from resources.login import login
2021-01-13T12:26:52.122436111Z File "/tmp/8d8b7be59131faf/resources/login.py", line 2, in <module>
2021-01-13T12:26:52.122440411Z import Requests
2021-01-13T12:26:52.122444211Z ModuleNotFoundError: No module named 'Requests'
2021-01-13T12:26:52.146770052Z [2021-01-13 12:26:52 +0000] [40] [INFO] Worker exiting (pid: 40)
2021-01-13T12:26:52.259319238Z [2021-01-13 12:26:52 +0000] [37] [INFO] Shutting down: Master
2021-01-13T12:26:52.259915039Z [2021-01-13 12:26:52 +0000] [37] [INFO] Reason: Worker failed to boot.
/home/LogFiles/2021_01_13_lw0sdlwk000307_docker.log (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/2021_01_13_lw0sdlwk000307_docker.log)
2021-01-13T12:22:51.236Z ERROR - Container apidevdeheus_0_01a16080 for site apidevdeheus has exited, failing site start
2021-01-13T12:22:51.243Z ERROR - Container apidevdeheus_0_01a16080 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:22:51.245Z INFO - Stopping site apidevdeheus because it failed during startup.
2021-01-13T12:26:39.844Z INFO - Starting container for site
2021-01-13T12:26:39.847Z INFO - docker run -d -p 4261:8000 --name apidevdeheus_0_801ae517 -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:26:44.872Z INFO - Initiating warmup request to container apidevdeheus_0_801ae517 for site apidevdeheus
2021-01-13T12:26:54.498Z ERROR - Container apidevdeheus_0_801ae517 for site apidevdeheus has exited, failing site start
2021-01-13T12:26:54.517Z ERROR - Container apidevdeheus_0_801ae517 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:26:54.584Z INFO - Stopping site apidevdeheus because it failed during startup.
/home/LogFiles/webssh/pm2.log (https://apidevdeheus.scm.azurewebsites.net/api/vfs/LogFiles/webssh/pm2.log)
Ending Log Tail of existing logs ---
Starting Live Log Stream ---
2021-01-13T12:17:45.663Z INFO - Starting container for site
2021-01-13T12:17:45.663Z INFO - docker run -d -p 1289:8000 --name apidevdeheus_0_0eaa3604 -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:17:53.138Z INFO - Initiating warmup request to container apidevdeheus_0_0eaa3604 for site apidevdeheus
2021-01-13T12:18:09.304Z ERROR - Container apidevdeheus_0_0eaa3604 for site apidevdeheus has exited, failing site start
2021-01-13T12:18:09.315Z ERROR - Container apidevdeheus_0_0eaa3604 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:18:09.430Z INFO - Stopping site apidevdeheus because it failed during startup.
2021-01-13T12:18:43.683Z INFO - Starting container for site
2021-01-13T12:18:43.684Z INFO - docker run -d -p 2042:8000 --name apidevdeheus_0_a93bbe2c -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:18:47.874Z INFO - Initiating warmup request to container apidevdeheus_0_a93bbe2c for site apidevdeheus
2021-01-13T12:18:55.667Z ERROR - Container apidevdeheus_0_a93bbe2c for site apidevdeheus has exited, failing site start
2021-01-13T12:18:55.686Z ERROR - Container apidevdeheus_0_a93bbe2c didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:18:55.696Z INFO - Stopping site apidevdeheus because it failed during startup.
2021-01-13T12:18:56.215Z INFO - Starting container for site
2021-01-13T12:18:56.217Z INFO - docker run -d -p 3004:8000 --name apidevdeheus_0_7e241d2b -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:18:59.851Z INFO - Initiating warmup request to container apidevdeheus_0_7e241d2b for site apidevdeheus
2021-01-13T12:19:07.196Z ERROR - Container apidevdeheus_0_7e241d2b for site apidevdeheus has exited, failing site start
2021-01-13T12:19:07.218Z ERROR - Container apidevdeheus_0_7e241d2b didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:19:07.229Z INFO - Stopping site apidevdeheus because it failed during startup.
2021-01-13T12:19:11.174Z INFO - Starting container for site
2021-01-13T12:19:11.175Z INFO - docker run -d -p 7941:8000 --name apidevdeheus_0_4a46b74c -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:19:14.875Z INFO - Initiating warmup request to container apidevdeheus_0_4a46b74c for site apidevdeheus
2021-01-13T12:19:22.137Z ERROR - Container apidevdeheus_0_4a46b74c for site apidevdeheus has exited, failing site start
2021-01-13T12:19:22.145Z ERROR - Container apidevdeheus_0_4a46b74c didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:19:22.160Z INFO - Stopping site apidevdeheus because it failed during startup.
2021-01-13T12:22:39.579Z INFO - Starting container for site
2021-01-13T12:22:39.580Z INFO - docker run -d -p 5705:8000 --name apidevdeheus_0_01a16080 -e WEBSITE_SITE_NAME=APIDEVDEHEUS -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=apidevdeheus.azurewebsites.net -e WEBSITE_INSTANCE_ID=43631460bf86d7f40d5b93bbd6d2c1c23daa6bc69ba1ff6fc850102219312bc3 -e HTTP_LOGGING_ENABLED=1 appsvc/python:3.7_20201112.3
2021-01-13T12:22:43.354Z INFO - Initiating warmup request to container apidevdeheus_0_01a16080 for site apidevdeheus
2021-01-13T12:22:51.236Z ERROR - Container apidevdeheus_0_01a16080 for site apidevdeheus has exited, failing site start
2021-01-13T12:22:51.243Z ERROR - Container apidevdeheus_0_01a16080 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2021-01-13T12:22:51.245Z INFO - Stopping site apidevdeheus because it failed during startup.
that's ocodigo app.py
from flask import Flask
from flask_restful import Api
from resources.login import login
app = Flask(__name__)
api = Api(app)
api.add_resource(login, '/login')
if __name__ =='__main__':
app.run(debug=True)
that's ocodigo login.py
from flask_restful import Resource, Api
import Requests
import json
import base64
import getpass
class login(Resource):
def get(self):
url = "https://login.microsoftonline.com/{tenant}/oauth2/token"
payload='client_id= &client_secret= &grant_type=client_credentials&resource=https%3A%2F%2F.sandbox.ax.dynamics.com'
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'fpc={token}; x-ms-gateway-slice=estsfd; stsservicecookie=estsfd'
}
response = Requests.request("POST", url, headers=headers, data=payload)
t = json.loads(response.text)
token = t['access_token']
arquivo(token)
def arquivo(token):
url = "https://dhnamics- .sandbox.ax.dynamics.com/api/services/CeServiceGroup_PTR/CeServices_PTR/getBoletoBinary"
payload="{\r\n \"dataArea\": \"\",\r\n \"recId\": ,\r\n \"tableId\": \r\n}"
headers = {
'Authorization': 'Bearer '+token,
'Content-Type': 'application/json'
}
response = Requests.request("POST", url, headers=headers, data=payload)
arquivo = json.loads(response.text)
Abase = arquivo['parmResult']
usuario = getpass.getuser()
pdf = base64.b64decode(Abase)
pdf2 = open("C:\\Users\\" +usuario+"\\Downloads\\boleto.pdf", 'wb')
pdf2.write(pdf)