How to deploy flask GUI web application only locally with exe file? - python

I'd like to build a GUI for a few Python functions I've written that pull data from MS SQL Server. My boss wants me to share the magic of Python & SQL with the rest of the team, without them having to learn any coding.
I've decided to go down the route of using Flask to create a webapp and creating an executable file using pyinstaller. I'd like it to work similarly to Jupyter Notebook, where you click on the file and it opens the notebook in your browser.
I was able to hack together some code to get a working prototype of the GUI. The issue is I don't know how to deploy it. I need the GUI/Webapp to only run on the local computer for the user I sent the file to, and I don't want it accessible via the internet (because of proprietary company data, security issues, etc).
The only documentation I've been able to find for deploying Flask is going the routine route of a web server.
So the question is, can anyone provide any guidance on how to deploy my GUI WebApp so that it's only available to the user who has the file, and not on the world wide web?
Thank you!

So, a few assumptions-- since you're a business and you're rocking a SQLServer-- you likely have Active Directory, and the computers that you care to access this app are all hooked into that domain (so, in reality, you, or your system admin does have full control over those computers).
Also, the primary function of the app is to access a SQLServer to populate itself with data before doing something with that data. If you're deploying that app, I'm guessing you're probably also including the SQLServer login details along with it.
With that in mind, I would just serve the Flask app on the network on it's own machine (maybe even the SQLServer machine if you have the choice), and then either implement security within the app that feeds off AD to authenticate, or just have a simple user/pass authentication you can distribute to users. By default random computers online aren't going to be able to access that app unless you've set your firewalls to deliberately route WAN traffic to it.
That way, you control the Flask server-- updates only have to occur at one point, making development easier, and users simply have to open up a link in an email you send, or a shortcut you leave on their desktop.

Unfortunately, you do not have control over a give users computer.
You are using flask, so your application is a web application which will be exposing your data to some port. I believe the default flask port is 5000.
Regardless, if your user opens the given port in their firewall, and this is also open on whatever router you are connected to, then your application will be publicly visible.
There is nothing that you can do from your python application code to prevent this.
Having said all of that, if you are running on 5000, it is highly unlikely your user will have this port publicly exposed. If you are running on port 80 or 8080, then the chances are higher that you might be exposing something.
A follow up question would be where is the database your web app is connecting to? Is it also on your users machine? If not, and your web app can connect to it regardless of whose machine you run it on, I would be more concerned about your DB being publicly exposed.

Related

make flask application work for certain perio similar to trail software

I'm currently developing flask application for a client and i want to give him/her to test it in there local machine. Issue is that i don't have internet connect or remote access in their system so I'm forced to add all source code i did to their system. i want to know is there a way i can give the client flask application without providing him/her with source code.
My objective is to make source code hidden of flask application whether it by executable file or have 30days for testing and after 30days application will automatically be deleted or disabled from their system it similar how trial application work.
If anyone can guide me into how can i make source code of flask hidden from client when i don't have any access to PC or internet that flask application is installed in

Making django web application accessible from other machines without deploying to a cloud

I have a django web application and normally, it works on AWS but one of our customers wants to use this web application on localhost because of the security. Also he wants to use this application with more than one computer on the same host. How to make a roadmap for that without sharing source code?

Is it possible to get access to PC system via web app using modules like pyautogui and win32gui/pywin32?

As a training project i have made activity tracker using python (no GUI, only command-line).
Script checks with win32gui/pywin32 and pyautogui what program is currently used, and if it is web browser what web site is in use.
Name of window, date, and amount of time spent on program/website is stored in sqlite3 database.
Then with help of pandas module same names are grouped and time is summed up.
I want to convert this script into web app using django but i am beginner in creating web apps, so i am wondering: is it possible to use this modules within django and is it even possible to create web app that works same as script mentioned earlier?
Sorry if the question is trivial. I will be grateful for every tip where and what exactly to look for in this topic.
Nope.
You can't make a server to connect through a web client/browser and see the other processes. That's a security issue, a big one.
Btw, some GNU/Linux desktop environments won't even allow the same user's processes in the same logged-in session on the same computer to see each other (Wayland).

Connecting iOS app to Windows/Linux apps

Background:
I am just about to start development on an mobile and desktop app. They will both be connected to a local wifi network (no internet connection) and will need to communicate with one another. At the outset we are targeting iOS and Windows as the two platforms, with the intention of adding Linux, OSX, and Android support in that order. The desktop app will largely be a database server/notification center for receiving updates from the iOS apps and sending out the data to other iOS apps. There may be a front end to the desktop app, but we could also incorporate it into the iOS app if needed.
For the moment we just want the iOS app to automatically detect when it is on the same network as the server and then display the data that is sent by that server (bonjour like).
As far as I see it there are two paths we could take to implement this
Create a completely native app for each platform (Windows, Linux, OSX).
Pro: We like the ideas of having native apps for performance and ease of install.
Con: I know absolutely nothing about Windows or Linux development.
Create an app that is built using web technologies (probably python) and create an easy to use installer that will create a local server out of the desktop machine which the mobile apps can communicate with.
Pro: Most of the development would be cross-platform and the installer should be easy enough to port.
Con: If we do want to add a front-end to the server app it will not be platform native and would be using a css+html+javascript GUI.
Question:
My question is how would implement the connection between the iOS app and server app in each circumstance.
How would I receive and send notifications over a local network.
How could I connect to the server using NSURLConnection if it does not have a static ip?
I hope this is clear. If not please ask and I will clarify.
Update 09/06/2013
Hopefully this will clear things up. I need to have a desktop app that will manage a database, this app will connect to iOS devices on a local wireless network that is not connected to the internet. I can do this with either the http protocol (preferably with a flask app) or by using a direct socket connection between the apps and the server. My question is which of the above two choices is best? My preference would be for a web-based app using Python+Flask, but I would have no idea how to connect the iOS app to a flask app running on a local network with out a static ip. Any advice on this would be appreciated.
Without any details of the application or frameworks its hard to be more than vague and point you in the right direction. If you have already explored Bonjour/Zeroconf to connect the iPhone to the server, I'd keep looking down that path.
The first place to look is PyBonjour for how to broadcast the server from Python. Although there are a few issues in how to configure this on Windows vs. Mac vs. Linux, this will be slight. For example, for windows the user will need to install Bonjour for Windows, where as Linux users will need Avahi, but most of this can be setup durin install.
Secondly, look at the Bonjour documentation for iOS, which will be much easier as its all built into the system and APIs. From here both server and client are discoverable to each other.
The last issue is determining if you want the iPhone to connect to the server or vice versa, and how. These however are basic networking decisions that more or less subjective.
Since you've indicated a preference for web development, you could easily have the iPhone connect to the Flask server and retrieve details from the server using HTTP/HTML technologies.
With regards to notifications, unless a change in data by client A means that client B absolutely needs to know about the change in data, I would not worry. The next time client B connects to the server, the correct data can be push through at that point rather than worrying with notification services. If another client does need to know about a change, another solution may just be regular old email that advices them, and prompts them to open the app.
I would definitely suggest a webapp. And the answer to your questions are given below:
How would I receive and send notifications over a local network.
Use a REST based web service to communicate with the server.
You have to use polling to receive data:-(
How could I connect to the server using NSURLConnection if it does not have a static ip?
If possible configure a domain name in your network which points to server ip. (Configure local DHCP to give same IP to your server every time based on mac address!)
Have a IP Range and when the app starts, try to reach a specific URL and check if it is responding.
Ask the user to enter the server IP every time the app starts!

Deploy python application

I am developing an application for managers that might be used in a large organisation. The app is improved and extended step by step on a frequent (irregular) basis. The app will have SQL connections to several databases and has a complex GUI.
What would you advise to deploy the app ?
Based on my current (limited) knowledge of apps in lager organisations I prefer a setup where the app runs on a server and the user uses a thin client via the web. I prefer not to use a webbrowser because of (possible)limitations of the user GUI. The user experience should be as if the app was running on his own laptop/pc/tablet(?)
What opensource solution would you advise ?
Thanks !
If possible, make the application run without any installation procedure, and provide it on a network share (e.g. with a fixed UNC path). You didn't specify the client operating system: if it's Windows, create an MSI that sets up something in the start menu that will still make the application launch from the network share.
With that approach, updates will be as simple as replacing the files on the file server - yet it will always run on the client.

Categories

Resources