I am trying out Python on Bluemix. To do this I decided to move an example from a book that worked fine on my Windows laptop. I created the Bluemix example app, then replaced the index.html with the html file from the sample and built my directory tree beneath the static directory. The server starts up fine and displays the intro html file as expected, but when I click on a link that should build my html page it displays the page as source code instead of executing it. On Windows this works perfectly. My call to the page looks like this:
My data.
I have heard that on Linux environments you sometimes need to point out the python executable, but what is the right location of that in a Bluemix environment? Another question would be if the .py file is set to executable, but I don't know how you set such a thing in Bluemix.
All help is appreciated.
You can't directly link to a Python file in a Python webapp. You should use something like Flask to serve your application. Flask can do routing for you.
Additionally, in Bluemix and other Platform as a Services' there is only a single binary entry point to your app. You can't have multiple binary entry points.
See this example app on how to deploy a Flask app.
Additionally, you can click the button below to directly deploy the example app to Bluemix.
Related
I’m working on a project that will need to load python code files dynamically from GitHub on launch. Here’s what it needs to look like:
User asks us to launch an instance for them and provides us with a GitHub url
We have an existing docker with our own python code (a server) that will be using those files from GitHub
We need to launch the docker with our own code, but subbing in parts that we got from the users GitHub, basically creating a server with half our code, half user code
In other words, we need to launch a docker that has some pre planned code from us, and some dynamic code from the user.
Any ideas how to do this? I’ve seen many examples of docker files that load code from GitHub, but I’m having a hard time figuring out how to make it half our code, and half code dynamically from GitHub on run.
So I have developed a python script which opens Slack app (which is based on Chromium) with a remote-debugging-port, and then injects a JavaScript bundle. Ideally I'd like to instead make a shell script which called the python file (and checked if python was available in the right version etc!) first.
This however would require the user to call the shell script from the terminal
What I'd really like would be a single executable file that contains:
the .sh script file
the .js bundle that gets injected
the .py file that the script calls
bonus, an icon that would show for the program in MacOS
It's been great developing the proof of concept so far, but creating an application is a new step to me. What is a way to create a (double)clickable file that contains the 4 files above and doesn't need to live in a terminal tab? Thanks
PS. This will always remain a simple app so simplicity is probably a key consideration.
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.
I've written a scientific program in python which outputs a .png and a .pdf
I would like to execute this main.py file from a web interface, with a nice big button saying GO and then display the .png and download a .pdf
I'm using a Django framework to serve the page saying GO. How do i get it to:
run my main.py file?
return the .png file to html template?
download the file which is generated by the main.py script?
Thank you internet
This question is a little broad for a specific answer, but in general, one can:
Have the button access an API which will, on the server, in another thread, your main.py file.
Once the application is finished, move the generated files to a deterministic location that serves static files on your web server.
Provide the user a URL to the newly created file's location.
Have a cron job run to clear out old files in the static directory.
new to GoogleAppEngine, this question may sound stupid... I just followed the tutorial and created a Python app, which is running locally with GoogleAppEngineLauncher. Is there any way to shell into the Python shell and play with the data structures in the running app? Thanks!
For locally running apps you can use the Interactive Console that is included in the Development Console.
The Interactive Console allows developers to enter arbitrary Python code into a web form and execute it inside their app's environment.
Navigate to the Development Console, click the Interactive Console link on the left pane. A form with a single text area will display. Enter any arbitrary Python code you like in the text area, then submit the form to execute it.
You can find more details in App Engine Python Developement Server documentation.
Google App Engine Remote API for Python: Using the Remote API Shell
This might be what you're looking for?