Raspberry pi - restrict user to the UI of a local web app and nothing else - raspberry-pi4

I am creating a fairly small vision project on inspection,
For interaction I have created a UI using HTML and hosting it locally using flask python.
(I created an HTML UI because I am familiar to it and other UI creation ways(like Qt, tkinter) are too time consuming)
Now what I want to achieve is:
auto login using a different user say with name of client_user.
Run the app directly on startup (which I know; by using systemctl service creation and enableing the same).
Then show the user only the flask hosted HTML UI and restrict the user to access anything at all. Something like a Kiosk maybe.
the user must be able to access anything else but the application itself
So here my main concern is to make point no. 1 & 3 happen (hoping that point 2 will still work irrespective of the way of implementation of point no. 1 & 3)
I have not been able to find any lead for the same (except that such devices, that restrict user to only one application, are known as Kiosks)
I am using Raspberry pi 4B with raspberry pi os 10 (buster)
Using python Flask as server.

Related

How to configure my app with capability "PrivateNetworkClientServer" and keep possibility to pass "WACK" test

I am working on Apache Cordova Win 10 Windows-x86 Store app for the data exchanging with the microcomputers collecting measurements, connected entirely to a local network.
I tested this app with capability "PrivateNetworkClientServer" and
deployed it in a form of "*.appx" package. It is working.
But "PrivateNetworkClientServer" capability is forbidden for Windows Store
with the setting in "package.windows10.appxmanifest" as this:
"uap:Rule Match="ms-appx-web:///" Type="include" WindowsRuntimeAccess="all" "
I have tried to change this setting or remove it (by default WindowsRuntimeAccess="none"),
but after running "build" this part of manifest was returned to its initial state.
How to configure my app with capability "PrivateNetworkClientServer" and keep
possibility to pass "WACK" test.
I appreciate any suggestions.
Thank you.
To have access from my Win Store App to web API in the local network I am using the "Fiddler4" exemption for now, but still hope to find more simple solution. The same Cordova app, but built with Visual Studio for Android, works in the same local network without any quirks.

How to detect whether a asp.net script is already running?

i want to create a script that would run forever. i mean i start the script today, and i should be able to see it running even in the next year.
this would not be possible because of the sever errors. it is obvious that the script will stop at least within 2 or 3 hours due to the server faults(im using a free web server).
so the method im going to use is to run two (or more) scripts simultaniously in two severs, and one scripts cheks if the other is runing & viceversa for every 30 seconds. and if found not running it executes the other one.
so the scripts will run as long as both of them are not stopped at once
1.my question is how do i check if the other asp.net script is running?
2.at least is there a way to check if another intance of the same asp.net script(in the same server) is already running?
i want to create a script that would run forever
ASP.NET is not the tool for this. A web application is a request/response system. It intercepts requests, performs a finite amount of processing, and returns a response. At that point it's done. Additionally, web servers are free to allocate and de-allocate resources for a number of reasons, so at any time your web application can be shut down.
What you're looking for is something more like a Windows Service or perhaps a Console Application (backed by a scheduler or something else to ensure that it's running). Web applications by design don't "run forever" so they're not the right tool for the job.
ASP is not free but it is also not too expensive, we can run a script on server that can continuously work on server, but doing such thing on server can cause server load error, and will affect other websites which are hosted on shared hosting. You can go for VPS hosting, But I think that your server administrator can suspended your account on running such kind of script on server.

How to run automated GUI tests on a remote headless ESXi Virtual Machine?

I'm trying to setup automated GUI tests in ESXi Virtual Machines using TestComplete. The problem, as I understand it, is that when no remote desktop connection is made to the ESXi virtual machine, then it is impossible for TestComplete to perform screen captures and therefore automate the GUI testing. As far as I understand it, this is due to the fact that Windows does not generate any user interface when nobody is viewing it.
I'm sure other have experienced this problem. How did you solve it ? Are you using a third party computer which automatically launch remote desktop connections prior to running the tests ?
Would it be possible to launch a remote desktop from a head-less virtual machine to another to fake somebody viewing ?
Any other smarter solutions I haven't thought about ?
You should be able to log in to Windows on the VM's console using the vSphere client, then close vSphere, and Windows will still believe the user is viewing the console. Simple as that. :)
So there shouldn't be a need to involve remote desktop in the mix.
As long as your tests then run as that logged-in Windows user, you should be fine.
This technique has always worked like a charm for me with certain Watir, Selenium, and MS UI Automation tests that depend on having an interactive desktop.
If you need to reboot the VM automatically before/during the test, instead of logging in manually in the vSphere client, you can make Windows log in as an arbitrary user automatically - check the "control userpasswords2" command, or you can use the Sysinternals app "Autologin":
http://technet.microsoft.com/en-us/sysinternals/bb963905
Only catch with this technique is that you need to be able to launch your tests while not viewing the console on the VM, but it sounds like you've already taken care of that?
If you need a solution for launching your tests remotely, I highly recommend using Jenkins or Hudson to kick off tests/collect results from the VM. Jenkins has changed my life in this regard.
You may consider using the Network Suites functionality of TestComplete:
http://smartbear.com/support/viewarticle/16849/
It can open Remote Desktop connections on its own, control tests on remote PCs, and pull the logs back to the "master" project. This feature is designed to be used for distributed tests, and looks like it's just what you need.
As for opening RDP to a head-less VM, it should not be a problem - it's up to Windows to "think" about this. You just open RDP and it works even if there is no monitor attached to the remote PC/VM.
I hope this helps,
Alex
You can always use VNC with checking the option "Do nothing" when disconnecting viewer. This way you'll trick windows to generate the image.

Data interchange across webpage and C++ backend components

I am thinking of designing a webbased frontend to a dataanalysis package. This is what I have in mind:
Data-analysis jobs are submitted to a queue.
People can login to the frontend and choose to run a job on the local machine or add a new job to the queue.
Details:
A person logs into the web-application and can either choose to run an exisiting job in the work queue on the local machine or assign a new job to the work queue
If a job is selected to be run on the local machine, the webpage queries the package installed on the local machine : "This is the job I have for you. How long would it take for you to finish this?"
2.1 The package would return a value (based on heuristics) to the webpage
2.2 The webpage can, depending on the value returned, choose to
allocate the job to the current
machine
2.3 If the job is allocated to the current machine, the backend package
goes on its way all the while
keeping the webpage updated with the
progress it is making.
A job can take from a few seconds to
a few hours to finish.
2.4 Any time the webpage can tell the package "You are taking too long -
send me what you have" or perhaps "I have something more important for you -
send me what you have".
The package can send the data it has by connecting to the webapp backend
directly at this point.
This needs to run on Windows and Linux - so I will be using the npapi plugin architecture.
The webpage would do most of the interfacing via Javascript.
My questions are:
How do I make the C++ npapi plugin return a value (a json structure) to the webpage javascript and then have a function in the webpage execute without the webpage asking the plugin to do it (to achieve 2.1). That is - the plugin initiates the interaction instead of the usual "webpage asks the plugin to do something"
Is there a better way to implement 2.3 than setInterval?
How do I make the C++ npapi plugin return a value (a json structure) to the webpage javascript and then have a function in the webpage execute without the webpage asking the plugin to do it (to achieve 2.1). That is - the plugin initiates the interaction instead of the usual "webpage asks the plugin to do something"
Use this example.
Is there a better way to implement 2.3 than setInterval?
setInterval works well enough.

Send data to Com port from a web page

I'm new to web development so please, could you help me to understand if I'm working in the right direction?
There will be a webpage intended for our customers (not intranet) from where they can print labels. Some of the larger customers will have special label printers where configuration and printing using COM-port is the only acceptable option. Basically we have very limited knowledge and control over their environment.
The web-page itself will be a pretty simple html-page or more complex AJAX.
After the customer inputs all the data and happens to chose this type of printing we have following tasks:
1) get data about the printers on the customer's system installed to a comport and if possible get printer settings (like paper size and orientation). Ideally would like to be able to adjust the settings, but if it is a pain can just put into requirements that your printer must be installed to COM1 and configured correctly.
2) send commands and read answers and send PCL code to the selected com port
As I understand I'll need to install something on the customer's machine to be able to talk to com port and get any settings. Just HTML+Javascript are not capable of doing that. Right?
I found RXTX library which seems to communicate to com port on most platforms. Can it be called from JavaScript or I still need to do a Java plugin? Are there technologies other than Java plugin that would solve the task?
The web-page will be used in different environment - platforms and web-browsers. We would like to minimize the number of customized solutions. Will Java allow us to do the same plugin for all environments with minimal customization?
If we require the user to install a plugin will the user be prompted with our credentials to confirm the installation? Will our web-site require higher trust settings?
Thanks for you help!
Well, I've had to do this in the past. Here is what I did and the circumstances
1) I knew that our customers were in a windows environment so I wrote win32 software to handle the printing.
2) I created a file format to be read by the win32 software that allowed me to specify print parameters and the label data. XML works ok for things like this.
3) My web app created a file in the format used by the win32 software and returned it to the user when they clicked on the "Print Labels" button. The file extension on the file returned was registered by the installer of the win32 software. That means when their browser looked for a default app handler for that file, it found my win32 software.
Bottom line is that the browser is handing off the printer communications to a native application instead of talking directly to the printer.
Obviously you need to be able to dictate your end user's are using a windows machine (or mac or whatever you can write native code). Associating a file extension with my program and returning that file to the user was the key to making the process work for me.
Whether your native code sends pcl directly to the printer or translates into a print api (like the win32 api as mine does) is another consideration.
Another approach you could consider is instead of sending PCL codes, you could create a PDF of the document. Format the document to the size and orientation of the label printer. The user will still have to hit the print button, but that might work. I have done this for printing to bar code printers and it works fine. Sometimes getting the margin and orientation correct is a little tricky, but that can be figured out.

Resources