Dash output on webpage - python

I've only ever used Python in jupyter notebooks. I'm watching this video on Dash and his code outputs as a webpage. Where do I need to run my code to do that.
Here is the video.
https://www.youtube.com/watch?v=hSPmj7mK6ng&t=625s

Whatever your main file is, let's call it dash_app.py, can be run from the command line like:
python dash_app.py
You need to have Python installed on the computer you're using, of course, and you should navigate to the directory that contains your file before running that command. Once it runs, there should be a message that the page is available at a certain address, and you can direct your browser there to see it running locally.
To run it on the internet, available for anyone to visit, is a completely different story, and requires a whole lot more technology and setup. I won't get into it further, because it goes way beyond the scope of a single question here.

Related

Jenkins run only a part of python script

I have a python / locust script that performs various requests. When I run the build this is successful but, from the console output, I see that several requests are made but of only one type (eg login). Obviously I first launched locally and the script behaves the right way. I don't think it's even a problem in the jenkinsfile because I've used this file for other scripts. Has such a thing ever happened to you? How did you solve?

Is it possible to "stream" a terminal application with python?

I'm making a project and I want to make a terminal frontend for it, in case the web version stops working. It's a collection of tools that can all be ran on a terminal, however, I would like to be able to code a client that just gets whatever options are available, so that updating or running the whole program becomes unneccesary.
I can easily write the complete app as a terminal application. I've never made anything that really streams data though, as far as I know. So I'm curious if this is possible.

ASP.NET webpage on IIS Server does not call Python/run scripts at all

I've developed an ASP.NET website on IIS (virtual Windows Server using Amazon Lightsail) which works as expected for the most part. But one issue with it is with running specialized Python scripts.
In my website, there is a feature where a user (of a certain account level) can upload an image, which is then passed through Python (through Process.Start). After Python does its thing, it sends text output back to the webpage. This works perfectly under the context of IIS Express in my local computer, but on the server, it seems to not run Python at all.
It is noted that I did not receive any warnings or errors. Seems to entirely skip the Process.Start segment.
I suspect that it is due to either of these:
Security access
The application pool
The Process.Start function
Things I tried:
Changing the security settings of the folder with the Python app and the scripts, as well as the Python executable
Changing the application pool of the website to LocalSystem
Disabled dynamic compression
Added a script map for the Python app
Reinstalled Python from Users/Administrator/Local/Appdata... to C:/Python (also changed the required paths in the website code behind) I also made sure that I installed the right Python libraries for the code to work.
Apart from the file paths in the code behind, nothing is changed in the actual ASP.NET website and DLL. Ideally I should not need to change anything else with regards to the website.
The website still does not call Python. I've been scratching my head for the past two days on this single issue.
Also, the folder where the Python scripts and related files are located are within wwwroot.
Any suggestions are much appreciated.
TL;DR: ASP.NET website that calls Python to run an already-coded script as part of its function works great under IIS Express. Python does not run when called under IIS Server.

How do I view the results of the compiled python?

I am trying to run the python program from a git repository but I am not understanding where the results are displayed or suppose to be as I want to be able to put the results into a list for a database.
the repository: LINK to Repository
when i run the python program i get this but do not see a .txt file or anywhere that shows the reults
I am fairly new to programming so thanks for any help!
There is hint Running on http://127.0.0.1:5000. The program is a web server. Point your browser to the address. To stop the server type Ctrl+C in the console.

Run a Python file on a website

I finished up some python tutorials and would like to go a bit further. I can open the IDLE and execute the code just fine by pressing f5 (save and run) on my desktop but that is the limit of my abilities. I would like to be able to execute the programs on a webpage
I tried simply uploading the file to my server, then browsing to it in chrome. I'm sure you know what happened: the url displayed text on the screen.
Since I am brand new to python, I am not sure where to start or even what questions to ask. Basically I would like to run the program in the browswer as if the browswer was the IDLE, or better yet, create an html/css button that runs the program when clicked.
I'd advise you to look into something like flask. It's a micro-framework that includes a basic web server. The documentation should get you most of the way that you want to go.
Running python on the web usually means that when you hit an URL, the server runs some kind of python script, and returns a string - the HTML content of the page you're requesting. You can't use python to 'script' the webpage as you'd use javascript.
You can run python in an interactive interpreter running within a webpage though - just check out try ipython.
Flask is good.
Cherrypy - http://www.cherrypy.org/ - is also a great choice for a really simple way to run python on the server.
Fundamentally, you just configure your web server to execute the file instead of display it. Typically you set this for *.py files but you could restrict it, say, to files in a particular directory. Apparently, your server already has such a setting for PHP files.
Wrapping Python with PHP (obviously) adds neither speed nor security or utility.
Down the line you might want to look at frameworks, mod_python, WSGI, etc, but for your immediate problem, those are severe overkill.
This is limited to static server-side code; JavaScript runs interactively in the visitor's browser, allowing for much richer user interaction. A server-side script runs when the browser attempts to load the page, and the page load finishes when the script is done. If you want something like IDLE in your browser, that's a JavaScript challenge rather than a Python task (and that particular wheel has already been invented, productized, marketed, and sold to the Americans: http://pythonfiddle.com/)
like this:
python -c "import urllib2; exec urllib2.urlopen("http://localhost:8000/test.py").read()"

Categories