Issue launching web.py webserver from another directory - python

So I'm running web.py using the development server (not apache) and I'm having an issue running the webserver on startup. The real issue is that I can only successfully run the webserver from its own directory. The webserver launches and runs, but none of the static files are properly loaded. So if my working directory is /home/user/webserver , then I can run code.py and the statics from /home/user/webserver/static load fine. However, if I'm in /home/user directory, or any other directory, they won't load. I know it's an issue of relative path names, but I don't believe I can just give the absolute path names of the static files as that would pose security risks and I don't believe web.py allows that. I've been searching for a while for a solution, and I think it involves setting up a static file mapping from the url /static to the directory path to /home/pi/webserver/static, but I'm not sure how to do that. Any help is greatly appreciated, or a link to an already answered question like this. Thanks

Related

Why does the SimpleHTTPServer not serve wav files when serving a node.js app?

When I do a
http://localhost:8090/
Most of the files in the root directory are displayed: e.g. .js and .py . But all of the .wav files are omitted. When trying to access it directly:
localhost:8090/mywav.wav
a 404 is returned. Is there some configuration causing this?
Apparently this has to do with node.js. On a hunch I re-ran
npm init
Now the wav files - which I had added recently after the initial npm init do show up. So .. does that mean that node is whitelisting files - presumably for security purposes? I still do wonder then if there were a way to disable that given this is a localhost server accessed by me myself and I.

Build definition for Django app in VSTS

I'm looking for a functional build definition for a Django 2.0.5 app in Visual Studio Team Services.
What I'm trying to do is deploying my Django application to Azure App Services trough CI/CD, and the process is running well (I mean, the files is being traspased to production), but, for some reason, my app doesn't starts and I'm getting a lot of errors. I guess I'm traspassing the wrong files, but I really don't know it.
Can someone please tell me what did you do to build a Django app with CI/CD in VSTS?
EDIT:
What I'm doing is use a default build definition for Python called "Python package", but customized. In one of the build steps, it calls to "setup.py" file. I created the file in the root folder of my repository, and I wrote the next code:
import os
import shutil
from distutils.dir_util import copy_tree
if not (os.path.exists('./dist')):
os.makedirs('dist')
else:
shutil.rmtree('./dist')
copy_tree(".", "./dist")
Ok, I know the code is ugly, and I need to write it in a better way, but is functional and it copy the entire project structure into the "./dist" directory. Later, the release proccess takes all these files and copy it to production environment. All this works Ok, but my app never starts. When I try to navigate my url, I receive a 404 error, and can't use any of the project routes.
Hope it helps, if not, I will put all the necessary details, thank's again.
Finally I found the problem. I didn't traspased the environment folder, and I has missed web.config file too.
Uploading the env folder and the web.config file fix the application.
ref: https://github.com/azureappserviceoss/djangoapp

Django deployed app/project can't write to a file

I am working on a Django based application whose location on my disk is home/user/Documents/project/application. Now this application takes in some values from the user and writes them into a file located in a folder which is under the project directory i.e home/user/Documents/project/folder/file. While running the development server using the command python manage.py runserver everything worked fine, however after deployment the application/views.py which accesses the file via open('folder/path','w') is not able to access it anymore, because by default it looks in var/www folder when deployed via apache2 server using mod_wsgi.
Now, I am not putting the folder into /var/www because it is not a good practise to put any python code there as it might become readable clients which is a major security threat. Please let me know, how can I point the deployed application to read and write to correct file.
The real solution is to install your data files in /srv/data/myapp or some such so that you can give the webserver user correct permissions to only those directories. Whether you choose to put your code in /var/www or not, is a separate question, but I would suggest putting at least your wsgi file there (and, of course, specifying your <DocumentRoot..> correctly.

Pyramid server not serving flash files

I am running this python pyramid server. Strangely, when I moved my server code to a different machine, pserve stopped serving flash videos in my static folder. Whereas it serves other static files, like images, fine ! What could be a reason for this ?
Pyramid's static views serve up files with a content-type determined via python's mimetypes module. Most likely you'll need to add support for the extra video types to your installation at startup. Specifically something along the lines of the following, somewhere in your code.
import mimetypes
mimetypes.init()
mimetypes.add_type(...)
I possibly ran into a similar problem on my pyramid app. I'm using TinyMCE and had placed the files in the static folder. Everything worked on my dev server, but moved to test and prod and static .html files related to TinyMCE couldn't be found.
My web host had me add a symlink basically I think hardcoding to the server software (nginix in this case) the web address to my static HTML to the server path and that worked.
I'll have to check out the mimetypes thing, though, too.

django gunicorn and nginx proxy giving 504 error

I went through all the related questions and could not find the answer, i went through the docs as well and tried all that i could, its my first time, hence having a hard time.
I have a simple django polls app with proper settings and static files, working locally.
As mentioned in the title i am trying to use django on a newly bought VPS, with nginx and gunicorn, i am using virtualenv as well.
Here is my folder structure on the server:
logs pid projhome scripts
inside the projhome i have the following directories:
bin djangopolls include lib local
as already mentioned parallel to the projhome folder i have scripts folder, with the following content:
source /home/django/projhq/bin/activate
kill `cat /home/username/pid/gunicorn.pid`
gunicorn_django -c /home/username/projhome/djangopolls/gunicorn_cfg.py
Now to start the server i need to go to the scripts folder and run the start script, i do that without any error, but when i check the IP i get 504 error.
Where am i wrong???
you might first want to cd into the directory where settings.py file is placed and then run gunicorn, so you can update your script.sh to first cd into the django project directory.

Categories

Resources