I have setup django with apache web server. It work but I noticed something strange.
Sometimes, the page that I load working normally. Then, if I press refresh it becomes error, page not found. If I keep refreshing, sometimes it returns to normal page sometimes it becomes error. After I restart apache, it always works fine.
I noticed this strange behavior appear if I tried to access some page that doesn't exist and give page not found error. Then, if I return back to the correct page, the strange behavior appears. It is as if the server or django has some cache to the error and then randomly display it.
How should I handle this?
EDIT:
Okay, it seems I know what happened. First of all, if I use apache+mod_wsgi, whenever I add some url, I need to restart the web server OR touch the wsgi app. Second, the trailing / in the end of the url really matter. I tried to access localhost/myproject/myapp is different from localhost/myproject/myapp/. That is why I got weird result.
Related
I am trying to automate my login to a webpage to download a daily xml. I understand that I need to have the actual frame url I think is
http://shop.braintrust.gr/shop/store/customerauthenticateform.asp
I examine the form and the fields and I do the following
browser = webdriver.Chrome('C:\\chromedriver.exe')
browser.get('http://shop.braintrust.gr/shop/store/customerauthenticateform.asp')
print('Browser Opened')
username = browser.find_element_by_name('UserID')
username.send_keys(email)
password = browser.find_element_by_name('password')
# time.sleep(2)
password.send_keys(pwd)
but I get a blank page saying that browser did a lot of redirections this means that it is impossible to login?
How can I login?
thank you
ERR_TOO_MANY_REDIRECTS
ERR_TOO_MANY_REDIRECTS (also known as a redirect loop) is one of the regular website errors. Typically this error occurs after a recent change to your website, a mis-configuration of redirects on your server or wrong settings with third-party services.
This error have no relation with Selenium as such and can be reproduced through Manual Steps.
The reason for ERR_TOO_MANY_REDIRECTS is that, something is causing your website to go into an infinite redirection loop. Essentially the site is stuck (such as URL 1 points to URL 2 and URL 2 points back to URL 1, or the domain has redirected you too many times) and unlike some other errors, these rarely resolve themselves and will probably need you to take action to fix it. There are a couple different variations of this error depending upon the browser you’re running.
Solution
Some common approach to check and fix the error as as follows:
Delete Cookies on That Specific Site: Google and Mozilla both in fact recommends right below the error to try clearing your cookies. Cookies can sometimes contain faulty data in which could cause the ERR_TOO_MANY_REDIRECTS error. This is one recommendation you can try even if you’re encountering the error on a site you don’t own. Due to the fact that cookies retain your logged in status on sites and other settings, in these cases simply deleting the cookie(s) on the site that is having the problem. This way you won’t impact any of your other sessions or websites that you frequently visit.
Clear Browser Cache: If you want to check and see if it might be your browser cache, without clearing your cache, you can always open up your browser in incognito mode. Or test another browser and see if you still see the ERR_TOO_MANY_REDIRECTS error.
Determine Nature of Redirect Loop: If clearing the cache didn’t work, then you’ll want to see if you can determine the nature of the redirect loop. For example, if a site has a 301 redirect loop back to itself, which is causing a large chain of faulty redirects. You can follow all the redirects and determine whether or not its looping back to itself, or perhaps is an HTTP to HTTPS loop.
Check Your HTTPS Settings: Another thing to check is your HTTPS settings. A lot of times it is observed ERR_TOO_MANY_REDIRECTS occur when someone has just migrated their WordPress site to HTTPS and either didn’t finish or setup something incorrectly.
Check Third-Party Services: ERR_TOO_MANY_REDIRECTS is also often commonly caused by reverse-proxy services such as Cloudflare. This usually happens when their Flexible SSL option is enabled and you already have an SSL certificate installed with your WordPress host. Why? Because, when flexible is selected, all requests to your hosting server are sent over HTTP. Your host server most likely already has a redirect in place from HTTP to HTTPS, and therefore a redirect loop occurs.
Check Redirects on Your Server: Besides HTTP to HTTPS redirects on your server, it can be good to check and make sure there aren’t any additional redirects setup wrong. For example, one bad 301 redirect back to itself could take down your site. Usually, these are found in your server’s config files.
I've tried to resolve my problem but didn't succeed. When I start the Development Server from Django, I try to access http://127.0.0.1:8000/, but when entered in the Browser it always adds the part /catalog at the end of the URL. I then get an Error (http://i.imgur.com/4eMEqkc.png). I know that it should show the site "It worked!". I have tried to delete all projects and reset all settignd I have changed but it still redirects me every time.
Has someone an answer to this problem?
solution: By deleting the browser data about the page it works.
I’m running a Django app on Heroku and have installed this piece of code: https://github.com/st4lk/django-solid-i18n-urls
It works just as expected on the Django built-in server, but when deployed to Heroku, I’m starting to see some really nasty problems.
I have Gunicorn running with multiple workers and if I use this code, the language preference starts to work randomly (I guess it depends which instance the request goes against).
For example if I have EN as the default (non-prefixed url) and DE as the second language, everything is working fine if I just browse the / urls. Now, if I switch to /de/ (manually enter URL or switch from the Django language switcher), the main / url starts to work intermittently – if I keep refreshing the page, I get either a 404 or the page in DE. But there’s no way to switch it back to using EN completely again. Same happens with all the other URLs as well, I get either a 404 or the corresponding page in DE. And there’s no way to force it back to EN, even from the Django’s set_language view.
If I never touch the /de/ urls, it works all very well without the prefixed URLs.
Does anyone have any ideas how to get this working also on Heroku and Gunicorn?
It turns out Gunicorn and the middleware override works fine, problem was with another piece of custom middleware.
In my GAE app when the request page is appid.appspot.com/module?action=form using the code snippet below I am getting this ouput appid.appspot.com/_ah/upload/?action=form/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t/
blobstore.create_upload_url('module/')
The URL I want to create should be like this
appid.appspot.com/module/_ah/upload/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t?action=edit
Is there a standard way to achieve this
No, you have not read the documentation. You don't get to control the upload URL: the parameter you pass is where the browser gets redirected to after the upload. The upload destination is controlled by GAE itself and cannot be changed from your code.
I had the same problem with my deployment. I don't know why it started happening with that setup beyond the fact that I was using a custom domain on the app (and removing it had no effect). In the end, though, it didn't seem to affect anything. Once I had my permissions set up right (oops) uploads worked fine despite the wonky URL.
i have been on this for the last 2 days with no result.
i am running my facebook app on my localhost with port-forwarding method.
i know my server setup is working fine as i can see the logs on the django runserver and dyndns log as well.
django is properly responding to calls as well.
the problem is as soon as the app authorizes with my user account, it straight follows to the page that says this:
Errors while loading page from application
The URL http://amitverma.dyndns.org/facebook_sample/?auth_token=817f8fbe99eff10582b634589de17b84 is not valid.
Please try again later. We appreciate your patience as the developers of app_test and Facebook resolve this issue. Thanks!
I am making a test app learning from facebook + django tutorial from here and here.
I am still getting this error and I have no idea what i am doing wrong...
Please help me out.
This often happens with a failed authentication. I'm not sure what the Python client libraries might look like, but with the PHP ones you generally make an authorization call against the library, something like $facebook->require_login().
With the PHP library, if this call fails to verify the user's Facebook session, then it automatically outputs HTML that will redirect the browser and try to re-establish the session, hence the auth_token parameter.
I suspect you're running into something similar. Try to isolate any authentication calls you're making, and use a Firefox extension like LiveHTTPHeaders to see if you are undergoing any redirects during the requests.
When you get that error, presuming you have debug=True in the Django settings and that your application is in development mode in Facebook, you can do View Source and see the entire Django error page that would normally display, including traceback. Facebook comment it out in the HTML so it doesn't show on the front end, but you can copy and paste it into a separate HTML file and view that in your browser to see the nice friendly Django error page which will definitely give you a clue as to what's going wrong.