On my RPi (b model) Flask is installed.
I can access the webpage "It works" via another browser on another computer.
Works great. As well on my LAN as from the outside world.
And also, I can write and run Python scripts and let it act as server and so on.
But how do I enable my own Python script for Flask as standard at boot from RPi.
It's seated in the /home/pi/myproject dir and I'd like it to be standard.
I can't find the standard python script and templates to replace.
Any help is welcome.
Related
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'm hosting a website on AWS. Its a web interface with a SQL database. The website will be used to:
1. View results of query from Database
2. Insert data into database
3. View the data and update it where needed.
The codes and connections works file when I run the application on localhost (Apache on my C drive). But we want to host it on AWS so that people around me can use it.
So, In AWS I uploaded the code on EC2 and installed apache on it, all the html links are working but the python file is simply displaying the code.
I'm guessing it has something to do with the shebang. Currently my code has the following shebang:
#!C:\Python27\python.exe
Can someone guide me if its the shebang or if there is something else i need to do.
I have installed boto, but not sure what to do next. The AWS website and most of the forums talk about using Elastic Beanstalk. I want to host a fully functioning Python webApp on AWS without using Elastic Beanstalk.
When apache displays code, that is a clear sign that Apache is not configured properly to execute python. You should look to see if mod_python is installed and configured correctly.
Also, #! is generally used with Linux not windows. If apache/mod_python is installed and configured correctly I can't imagine what code you'd have that would need #! since the .py extension would be enough.
IF your EC2 instance is indeed running Linux, and your code does indeed need #! try:
#!/bin/python
OR
#!/usr/local/bin/python
(Depends on where the python binary is, and those are the most common locations.)
If your EC2 instance is running Windows then "Unless you are using cygwin, windows has no shebang support"
Hi have you logged into your EC2 instance through the endpoint and then run your script, from the command line. I have some experience with EC2 running apache2 only my application was written in Java, having previously used python scripts I was able to run them by logging into my EC2 instance, you can do this from AWS management console. hope this helps you somewhat.
I have a Raspberry Pi running a Web server and I'd like to be able to create a web interface to change the colors and images on my RGB display.
I control the RGB display by navigating to the directory and executing a python file and it lights up, it ends up looking like
pi#raspberrypi: sudo python test.py
Cool, it works! But how can I execute this on my pi webserver, I don't even know where to begin. What sort of framework can I use to accomplish my goal here?
You could use for example flask or bottle. I like flask, which i use on my webserver. By the way it is also an Raspberry Pi. I think the most framework have a developer server, so you haven‘t set up a ‚real‘ webserver.
Maybe you could use Jupyter Notebook too, but i didn‘t try it on my Pi.
I have apache running on a Raspberry Pi. My website is using running Python scripts. How do I make, say, start.py, as the default document for the site? In other words, if the host name for the Raspberry Pi is pi, I want my users to just use http://pi and start.py will execute.
I would use apache's mod_fastcgi module, mapping a virtual host in apache to a script folder containing python scripts. Note however, this is far from production quality, or secure! However, if your Pi is on a trusted intranet network such as a home, it should be fine.
Here's one blog which spells it out, step by step: http://raspberryserver.blogspot.com/. The final step in the tutorial is to install apc, which you can skip. It's for PHP.
Essentially, you'll be able to drop python files into the /var/www/fastcgi folder, and profit.
I have downloaded and installed python on my PC. I am learning python at this moment so I am a beginner.
Is there anyway I could execute python scripts in localhost (Apache) and view them in a web browser as we do with PHP? I am executing the python scripts from CLI at this moment.
Although there are multiple solutions, I would take a look at mod_python. Unfortunately, in my experience it is not the easiest thing in the world to set up and requires making changes to httpd.conf, but this tutorial is helpful (and gives some examples).
Google App Engine SDK for Python includes a local web server application that simulates the App Engine environment. It allows for instant server script changes by just saving the file and refreshing the browser.
The development tutorial is here
Once you have your web site working locally, it is easy to deploy it live on Google's App Engine servers.