Categories
Mastering Development

show white page in webview when load (PDF url) url android

I try to load pdf URL into webview but sometimes URL load perfectly or sometimes displays the white page. it displays a white page because it directly calls onPageFinished method. I try with log in onReceivedSslError, onReceivedHttpError but when load white screen it calls onPageFinished method directly. How can I load every time my pdf […]

Categories
Mastering Development

Error handling: how to properly prioritize exceptions

There are two functions: one downloads the excel file (ExcelFileUploadView(APIView)) and the other processes the downloaded file(def parse_excel_rfi_sheet). Function parse_excel_rfi_sheet is called inside ExcelFileUploadView(APIView) class ExcelFileUploadView(APIView): parser_classes = (MultiPartParser, FormParser) permission_classes = (permissions.AllowAny,) def put(self, request, format=None): if ‘file’ not in request.data: raise ParseError(“Empty content”) f = request.data[‘file’] filename = f.name if filename.endswith(‘.xlsx’): try: file […]

Categories
Mastering Development

Creating a HTTP Mutation request in Golang for a json object

I am new to Golang and Graph ql. I have json object that needs to be passed as a mutation calling a mutation method. I am not able to pass the json in a conventional way as below, request, err := http.newRequest(“POST”,”https://countries.trevorblades.com/”, bytes.buffer(JsonValue)) as the mutation request should be something like this, mutation { createEntry( […]

Categories
Mastering Development

Charting JSON data from Flask and MySQL

I’ve stored JSON data into a MySQL database and now I need to pull specific elements out as needed for use with Chartjs (https://www.chartjs.org/docs/latest/getting-started/) <link rel=”stylesheet” href=”/static/assets/css/Chart.min.css”> <script type=”text/javascript” src=”/static/assets/js/plugins/Chart.min.js”></script> <canvas id=”canvas” height=”300″></canvas> MySQL’s cursor class is set to “DictCursor” in Flask so that it returns python lists instead of tuples – from flask import […]

Categories
Mastering Development

gRPC communication exception over client – docker – server model

Trying to do communication by gRPC in a client(c# – GUI) <–> server(python) <–> client(python) <–>server(c#). Setup: –> GUI in c#(grpc client) that connects with a Python service(inside a docker) that functions as a gRPC server. This setup works using the default “greeter” service used in many examples around on the web. –> Docker also […]

Categories
Mastering Development

How to display the success message or error message in the same page using nodejs?

This code is working fine, but I have to display the message in the same page using HTML tags. app.get(‘/home’,(request, response) => { //Here i have to use the response.render() pass the data to html page }); app.post(‘/sub’,(request, response) => { if(request.body.submit1) { let sql1 = “insert query…”; let query = connection.query(sql1); response.write(‘<script>window.alert(“Applied successfully”);window.location=”/”;</script>’); } […]

Categories
Mastering Development

How to set permissions per handler function with APIView?

I am writing an API for a small school-related project using Django and Django-Rest-Framework. I am trying to figure out permissions. I am using APIView for my views, and am looking to set different permissions for each handler method without writing more views. Here is one of the views for the blog module that I […]

Categories
Mastering Development

Django, REST framework – How to ensure absolute url will be returned for image?

I need viewset to return always absolute url for avatar / avatar_thumbnail image fields in response, but I’m getting relative paths. I have two such cases: 1st) is in image field in nested serializer, 2nd) is in viewset where I want to use two serializers in retrieve method. models.py class CustomUser(AbstractUser): avatar = ProcessedImageField(upload_to=’users/’,format=’JPEG’,options={‘quality’: 60}) […]

Categories
Mastering Development

Black image output only when using Flask

I have a main app.py script that calls the neuralStyleProcess.py script but it always outputs a completely black image. I’ve tested the neuralStyleProcess.py script by itself and it works fine. The problem only arises when I’m running on development server (when using app.py to call neuralStyleProcess.py). Here’s my codes: For app.py: # Import required packages: […]

Categories
Cryptocurrency Ethereum Mastering Development

Sending tokens out on coinpayments success payment using Web3py

I’m writing Django app and want to send out tokens using Web3 once Coinpayments sends me callback about successfull payment. The problem is that Coinpayments sends multiple callbacks at once and just in one case tokens are sending, other callbacks get replacement transaction underpriced error. I’ve already tried to use solutions like add +1 to […]