I have a Django app working fine on the local server but when I host it on the pythonanywhere (It is a cloud-based python site), there are some issues with the rendering on the template.
While I was coding on the local server, I used to use print statements to debug the functions in views.py, but how to use print statements for debugging if the site is deployed on the web because after hosting it on the pythonanywhere, I am unable to find where the output of the print statements goes to?
Please suggest another way, if this is not feasible, to get the backend output after deploying the Django web app.
Thanks for the help.
To do so you have to go on:
1)your web app: you have to replace yourusername by your real username in pythonanywhere.com
https://www.pythonanywhere.com/user/yourusername/webapps/#tab_id_yourusername_pythonanywhere_com
2) scroll to bottom where you can see : Log files and in this section your will find a server log click on that and you will be redirected to an other page where you can scroll to bottom from there you can see the print from your views.
i hope you understand and sorry for my poor english.
Short Solution
visit the server log file here
https://www.pythonanywhere.com/user/yourusername/files/var/log/yourusername.pythonanywhere.com.server.log replace yourusername by your real username in pythonanywhere
Related
I have the project successfully deployed through AWS. However, I would like to make some changes and experiment on them using localhost:8000/ first before making the changes to AWS server. I set my settings.py to: ALLOWED_HOSTS = ['IP address', 'www.website.com'] to deploy it. Though, I also want to be able to run the server in my local computer so I can experiment it before showing to public. The url is (r^homepage$') When I go to localhost:8000/homepage, it gives a Bad Request (400). I tried many permutations of the urls but nothing works.
you can set Debug=True to see the error message.
I have made flask web app meant to be used within my organisation.
My problem is currently the login works by requesting a username and password from the user which are then authenticated by an LDAP server.
I would like to be able to autologin a user immediately he gets onto the site since that's how other company internal websites work(these others were made in C# and php)
My main problem is:
Is there a python package to get the client's windows username immediately he gets on to the site? and how would I use it
Requests-ntlm was once suggested but it has no documentation.
I have tried to look at several stack overflow questions but they do not address my problem eg link
It has taken me weeks to find the answer but Yes it is possible but you must configure the server where your app is hosted to allow this. In my case I was using IIS and enabled windows authentication.
With this its surprisingly easy to get the active directory user name as it comes as part of the HTTP response:
from flask import request
username = request.environ.get('REMOTE_USER')
See this question for more information:
How to access Apache Basic Authentication user in Flask
The question explains mostly everything. I am writing a Django app which will use Facebook authentication through Python social auth. I created an app using Facebook developers. The thing is, I don't have the domain set up with my website as I am still testing on localhost. I could not put in the localhost URL in the Facebook app settings. When I try to login through localhost, it says the URL must match with the domain.
What to do now? Without testing, I cannot host my website either as I am not sure if everything will work like i want it to.
EDIT:
I created a test app and was able to put localhost:8000 as the site url and localhost as app domain. However, the same problem still exists. It says that the 2 urls has to match or something. NOTE: In my local host, the login is 127.0.0.1:8000/login/facebook. And yes, I did update the ID and the app secret for my test app.
What to do now?
You should be able to create a test app within Facebook (There is a 'Create Test App') menu option. It may be that you need to first create an App, and once you have it, you will be able to create the Test App for it, but for sure you can create a Test App.
On that test app, use http://localhost:8000/ as your local URL. Just make sure it is the exact same URL (i.e. you cannot have 'localhost' on Facebook, but then start the server for '127.0.0.1'). Note that the AppID and AppSecret you will use is of the Test App (not the production app).
This should work. I have not used this for python-social-auth but use this to test with django-allauth, and there is no reason why it will be any different.
I am very new to Google App Engine coding and have no idea how to resolve this. What I am doing is a very simple thing. I have designed and made a website on my local PC. Now to host it, I am using Google App Engine. So what do I do, I simply downloaded the python app engine launcher and uploaded my entire website on Google Apps. I have set all the redirects on the control panel of Godaddy! which has registered my domain name.
Now whenever I visit the site for the first time, I get "Hello world!Status: 302 Moved Temporarily Content-Type" message and then upon clicking refresh, it loads the website. How can I get rid of this?
Much appreciate your help on this.
Thanks
I'm currently developing a bottle app on GAE, and it's already got its own home-made authentication system. However, I would also like to permit access to some areas to application admins using Google Accounts. I'm looking at the documentation, but I'm not quite following it.
On the development server, hiting any _ah link sends me straight to the desired page, but on GAE, it gives me bottle's own 404 page. Can you point me to the right page where I can get started with this (preferably not the official docs which I'm having hard time with)?
NOTE: Forgot to mention it's a Python version of GAE.
_ah will work only on the development server. It's a part of appengine sdk which emulates the GAE. Coming to your point. If you want to use the google's account for admin functionalities. Then you should do something like this
from google.appengine.api import users
if users.is_current_user_admin():
Here admin refers to the appengine admin. if you want to simply use the google authentication
then you should use users.get_current_user() to get the current logged in user and implement your own logic.