-1

I have a script python for Reading biometric identity card with a card reader this script use this https://github.com/roeften/pypassport, i want to creat a web app with django and use this script and run it on client machine (on web browser) , each user can read his card with a card reader on this web application. how can i do that ? any idea can be useful looked at this part of script that I want to run on the client browser:

from pypassport.reader import ReaderManager
from pypassport.reader import ReaderManager

from pypassport.epassport import EPassport, mrz
r = ReaderManager()
reader = r.waitForCard()
p = EPassport(reader,"YOURMRZINFO")
p.register(print)
p.setCSCADirectory("C:\\TEMP")
p.doBasicAccessControl()
p.doActiveAuthentication()

p['DG2']
Dias
  • 44
  • 4
  • 1
    Instead of downvoting, I suggest structuring your question a bit better. Try to use punctuation marks consistently. Elaborate a bit more on what you want to do, and where you are stuck. Now to make a suggestion to your question: if you want a quick Minimum Viable Product, I would first have a look at Flask. You could then deploy your app on Heroku. – lcdumort Feb 03 '22 at 14:12
  • I suggest you to be careful with that library. As far as I know, it's very old and not well maintained, and the repo that you've linked is a fork of the original one (which I suppose has been dropped) with very small changes so that it works with python 3 (no minor specified), and it has no attention so issues haven't been raised. If I were you I'd try to find other tools for this. In any case, you can't really run python code on a webpage. What you can do is build the back-end of one with it, using Flask or Django. – Shinra tensei Feb 03 '22 at 14:26

2 Answers2

1

if you want to run it in common browsers like "Chrome, Firefox, Opera, Edge ...", that's impossible. python must in python Virtual Machine, Browser doesn't contain that.

jinger7281
  • 71
  • 2
  • There are web frameworks available such as Django and Flask. Is there any particular reason why this wouldn't work in OP's case? – lcdumort Feb 03 '22 at 14:14
  • is it possible to install it and call it from browsers like extension ? – Dias Feb 03 '22 at 14:21
  • @Dia no, you can't. You seem to want to build a client side tool. That is, a tool that runs in your browser. In this case, you need to use javascript. There's no way around it, it's all you can do unless you're brave enough to learn webassembly. – Shinra tensei Feb 03 '22 at 14:30
  • the code in the quest use local storage writing permission and may be serial port reading and writing permission, pypy.js can't do that. @Dia that's impossible for you when you ask this question, because first you must know some browser programming knowledge on permission and container for scripting language and some OS information. – jinger7281 Feb 03 '22 at 14:34
  • @Shinratensei webassembly also can't do that because of the security limitations of the browser – jinger7281 Feb 03 '22 at 14:36
  • damn I guess I've stumbled upon one of the few things webassembly isn't capable of doing – Shinra tensei Feb 03 '22 at 14:43
-1

you cant run python natively in the browser.

but ofc, there are workarounds, like pypy.js (this compiles python script to javascript and then runs the js)

alexzander
  • 1,586
  • 1
  • 9
  • 21