I have a Python / Django application which is supposed to call an external windows binary and get its output at some point. And it does so when tested via 'python manage.py shell'.
But when it is run from within the web browser, which is served by IIS, the external application is not executed.
Is IIS blocking something on the way? Can this be avoided?
Any help is much appreciated.
oMat
Might be a permissions issue. when you run from the shell, you're using the user that run the python manage.py shell command. When serving requests from the IIS you're using its user (IUSR or something like that). Try giving execution permission on the executable file to the Everyone group just to see if it helps.
Related
I was wondering how I could run some external python scripts on my django application while it is running with gunicorn and nginx ?
Locally without gunicorn and web server, I would just open a python shell using the below:
python manage.py shell
Then run my python script on my django application with the following:
exec(open('myscript.py').read())
Can you please advise ?
PS: I need to run the script on specific time and not on the startup.
Kind regards.
You can just import the script into one of your Django project files like settings.py and then it will just run at the same time.
I have a web application in flask that uses rest-plus for some CRUD operations. I'm using Swagger to test endpoints.
Recently i migrated my project to use new Flask CLI instead of Flask-Script (using Manager instance to add commands).
However there is a big change I've witnessed w.r.t. reloader...
Previously every time I made a change in code, after server was already running there was information about reloading, and traceback in case of error in terminal. I think whole application was restarted each time?
Now, after migrating to CLI there is no such thing (at least not visible in terminal) and in order to see error I have to open up my server in browser or refresh browser, and the traceback is visible both in browser and terminal afterwards also there is no information about reloading in terminal.
I'd like to know whether it's caused by this new CLI or maybe I messed something else up in the meantime.
Which behavior is the correct one and is there any way I can get back auto-reloading in terminal without having to refresh web browser each time?
Thanks in advance,
Cheers
Make sure you run your flask server in development mode. For example:
export FLASK_ENV=development
export FLASK_APP=app.py
flask run
The log should say something like:
* Environment: development
* Debugger is active!
My app is pretty slow even in a dev environment so I would like to figure out what's slowing it down so I can try and fix it.
I know about the debug toolbar and according to what it reports neither the database queries nor the downloaded sources are the issue, so it must be the business logic.
However, I cannot run the PyCharm profiler with the Django server because, well, it's not like running a script.
How may I profile Django with PyCharm?
You should probably set configuration properly.
Then click on Edit Configurations...
The main thing is to set Interpreter (your virtual environment). You don't have to set Custom Run Command if you use python manage.py runserver
Then you can run Django server directly from PyCharm ann Profiler too.
Hi I am new to Django and have been googling for a whole day without any success.
Basically there is a live/working website built with AngularJS, Django and PostgreSQL (Ubuntu 14.04) and I am trying to download all the files and clone the site into my localhost (Ubuntu 14.04).
After I downloaded the folder and finished install the required packages on my localhost, I run:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
The server runs without reporting any errors.
However, some of the links are directed to a 404 page, such as this:
http://127.0.0.1:8000/city/chicago
Whereas in the live site, it would direct to the correct working page.
Can someone tell me what may have gone wrong in the process?
Thanks.
Try editing the settings.py file set the DEBUG value to True. Instead of a 404 you should get a full debug of the actual request and see what exactly is missing (I suspect missing data as #NightShadeQueen pointed).
Also you might have a look at django debug toolbar which prints the executed sql queries as well and run them against your local database to see what exactly they return.
I am a newbie to web development and Python. Since I dont have the vocabulary to ask the exact question, here is a summary of what need to do:
I have a small test python cgi script, which i have uploaded to /home/username/pyscripts which is above the /home/username/domain.com
I need a link I can type in the URL bar, which will lead to the script being executed and the content displayed in the browser.
Can someone tell me If i need to create an html file, and if yes how to get it to point to the python script The domain folder has wordpress installed. My hosting is dreamhost shared hosting
The script is there below:
#! /usr/bin/python
print 'Content-type: text/html'
print ''
print 'Hello, World!
Heroku is a good place to host and python scripts.
Pre-req
pythonscripts.py
procfile
requirements.txt
and After add, commit and push the scripts to heroku app. Just run the following command on terminal to run the scripts.
heroku run python your_scripts.py
More if you want to run this scripts on a schedule timing. then heroku provides lots of adds-on. just search it on heroku
Usually you'd need to put your python script under the /home/username/bin/ folder. I'm not sure if your particular webhost actually allows you to run your Python script outside of the /bin folder (normally this is not the case), but if yes then you can substitute the /pyscripts folder.
The URL would look something like this: www.domain.com/bin/mypythonscript.py
Or with the pyscripts folder (if possible with your webhost): www.domain.com/pyscripts/mypythonscript.py
You don't need to create an HTML file as the first content line that you print in your Python script is telling the user's browser to display the output of the script like an HTML file. You simply type the URL to your python script into your browser and then the server runs the script and outputs it as a text/HTML file, which your browser then reads and displays.
Also, don't forget - you need to grant execute/read/write permission to your Python script file after you upload it to the correct folder on your webhost server or it won't run at all. Usually this is done through your upload utility like Filezilla or using a shell command like chmod.
Well dream host support python. Check if they are providing shell access deployment. All you need is create .py file and run it.
Then consider to use Django or Jinja2 like framwork. Its easy for creating web application