Convert flask web application to a offline PWA with python dependencies - python

I had a flask based web application built to generate QR code. I'm using pyqrcode module to generate the QR code. Now, I want to convert this flask app into a mobile application that works in a offline mode. Using PWA (progressive web applications) can I make an offline mobile app that can use python modules (pyqrcode in this case) to generate QR code. Can I somehow cache python modules to use them in offline. If not, should I develop an app with dedicated tech stack for mobile application development.
I tried to understand how PWAs work in offline mode. It needs to cache the required data used in offline mode. But my requirement is to use few python modules in offline mode. But, I know that I Won't be having any python environment dedicated to understand my application. I'm new to mobile application development. Any sort of help is appreciated. Thanks in advance!!!

Related

create android, iOS libraries from python, including dependencies

We working on a project which involves ML/AI integration to the native mobile application. We are programing our ML/AI code in python. Python code has dependencies, that we need to include in our mobile application.
We have tried with kivy but they only create .apk files and apk files can't be called from other apks. So, we need to create libraries that can be included in the android and ios projects.
Also, we tried chequopy but that doesn't support mediapipe which is in heart of our implementation.
Any guidance in that direction will go long way for us.
If your app was entirely self-contained in python including dependencies using recipes should be possible. If rewriting the native app is not an option maybe one idea is to serve the ML over an HTTP API running on a local server (eg flask). Quite cumbersome as users would need to install two apps

How can I distribute an Electron app with Python

I have a Python web application that I want to wrap in Electron. The web application backend is a very slim Flask app that forwarded calls to a Python package that does the processing, and formats the results. We have a React frontend that talks to this backend. We also have a pip based installation, that runs the Flask backend and serves the frontend, so you can pip install run the server and use it from your browser. This is similar to how Pgadmin 4 works.
Since this application is only used by people on their own computers, and never installed on a server, I want to convert it into an Electron app. However, I couldn't figure out how to distribute this application in one setup for Windows, MacOS and Linux. I don't want the users to have to install Python on their computers.
How can I do that?
There is a couple of clues on how to do that, even though I'm still unsure whether all necessary python modules can be bundled easily.
I have a similar case, even though I just want to bundle a prototype in an electron application so I can send it to collaborators for evaluation, without any intent of shipping it to final users.
My list of hints:
https://github.com/matbloch/electron-flask
https://efficientcoder.net/connect-python-3-electron-nodejs-build-desktop-apps/
https://www.techiediaries.com/flask-electron-tutorial/
I really don't see why you need to throw electron in the mix, instead of just using your browser. I reckon that a barebone electron app that serves your page in a single window is going to be 50Mb. The key benefits of electron is that it lets you do system calls (access local files / devices), but if you are running flask you already have this ability.
Your main obstacle is how to distribute the flask app, specifically without installing python - and electron is not going to make things any easier to that respect. You should probably look at pyinstaller which lets you create executables that embed python.
Now, if you're talking of getting rid of python altogether, then indeed you could do that, nodejs has a rich set of libraries for everything os / db-related, even image processing, but it will lack in data science and processing. YMMV.

How to publish python code as web api on iis

I am new to Python deployment. I have a Python Web API made in Flask. Want guidance on how to publish the python code as web API so that Dot Net program can consume it and take benefit of Python / ML.
Apologies for such generic question, but any help or approach or documentations on the same would be grateful.
Thanks In Advance!!!..
As far as I know, if you want to deploy python application to the IIS. I suggest you could follow below steps:
1.Install Python on your server.
2.Install wfastcgi on your server.
3.Install the IIS(contol panel->Programs->Programs and Features->Turn Windows Features on or Off) with the CGI
4.Create a new IIS web app for the paython project folder.
5.Modify the handler mapping to add python handler. Notice: Modify the path based on your python and wfastcgi path
Run your application
More details, you could refer to below article:
https://www.storehubs.com/Blog/deploy-python-flask-application-iis/
https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019

architecture on google cloud platform for scientific web application

I have an apps coded in python/pandas/scipy which can be launched by anyone authorized. I want to use Google Cloud Platform to host it but I can't find a good way to set up this.
Since I want my app to be a web app, part of this is hosted on google app engine, but since google app engine does not seem compatible with big calculus and scientific libraries, I think I shall send the task to a VM with the scientific libraries.
My questions are:
1- could I create a VM each time the app is launched, in order to save money? But if I do this, I have to setup pandas scipy etc... each time, which should take some time?
2- Am I condemned to have a VM running every time and activated by the app? But if two people launch the calculus together, this can be really bad perf?
3 - Shall I package my app as a .exe and launch it as a standalone?
I am totally lost on how to handle such an architecture, can anyone give me some advices?
Thank you!
You can host your application on Managed VMs. Applications that run on managed VMs are not subject to the restrictions imposed on the sandboxed runtimes (Java, Python, PHP, and Go).
You can also choose the hosting environment (sandboxed or managed VM) separately for each module in your application. This means an application can contain a mix of modules that use different hosting environments. For instance, you might use the sandbox environment for your client-facing frontend, and use a module running in a managed VM for backend processing.

Execute python script in localhost

I have downloaded and installed python on my PC. I am learning python at this moment so I am a beginner.
Is there anyway I could execute python scripts in localhost (Apache) and view them in a web browser as we do with PHP? I am executing the python scripts from CLI at this moment.
Although there are multiple solutions, I would take a look at mod_python. Unfortunately, in my experience it is not the easiest thing in the world to set up and requires making changes to httpd.conf, but this tutorial is helpful (and gives some examples).
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser.
The development tutorial is here
Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.

Categories