I am new to Python and django , I worked on C# and php as developer earlier.
My problem here is Entire Application in Django shuts down with single error.
for example i start my website with "python3 manage.py runserver 0.0.0.0:8000"
example:-- i have two pages home and register
1) if i make error in register page code(register.py) , It shuts down home page too. Is there a way to prevent that as in php and C# in both one page do not effect other.
2) how to work in django with team one errors full team hangs.
3) How to work with live working websites things may become too risky.
also i am not able to find article related to this.
kindly help
Related
Experienced with other cloud hosting providers I tried Digital Ocean the first time to set up a Wagtail app (should be a staging/production environment with pipeline in the future). Following this tutorial (but just deploying a SQLite database not a solid one), everything works fine. The app will be understand as a Python app when cloning it from GitHub and the default build process (by Python Buildpack) followed by running with Gunicorn server will be executed like expacted – there is no Dockerfile provided. Afterwards the frontend works as expected when first opening it. The admin panel allows to enter but when navigating to page editing it destroys the session and I´m faced with the login panel – probably auto logout, since expired session. The django-admin reacts the same way.
The tutorial uses get_random_secret_key. Maybe this is not accepted by Digital Ocean? Another maybe important information is that the set-cookie header first contains a expiry date in one year (like it is set). But after the session was destroyed it´s set to 1970 (probably something like a null value). Actually this is just the indicator for the forced ended session I guess.
Since it´s not so easy to find out, if it´s something which has to do with the code or safety measurements I didn´t share code. But I can do that of course, if it´s needed. It´s probably a issue not just for me and a hiint which is the cause could help other developers struggeling with this, too.
I am looking to create a very basic website that has a single feature. This feature works as follows:
1) The user inputs a URL to a website
2) My website will scrape the given website for necessary information
3) Apply whatever logic I need and return the processed information as a string
4) Allow user to download returned data in .txt format.
I am working on this project with one collaborator, and he has created the scraping and logic (steps 2 and 3) in Python. I have looked around stack overflow to see if it is possible to execute python scripts in a website, and the consensus seemed to be that I will require a server that executes python, and then make HTTP requests to my server.
Unfortunately, I'm quite a junior developer and lack a lot of understanding regarding web dev, and my attempts to "dive in" have left me with more questions than answers. We have a deadline that is approximately 3 days from now, and the only part that remains is to set up a server that can execute a specific python script upon HTTP requests.
I think that the source of my confusion is a lack of understanding regarding how exactly a server works, and was hoping that the kind folks here at stack overflow could help me in:
1) better understanding what's going on "under the hood" on the server side after an HTTP request arrives (or better yet, how does an HTTP request even arrive at all?)
2) Explain to me like I'm 5 what I'll need to do to deploy my website - namely all the in-between steps that receive little attention from the other posts here at stack overflow.
Some example questions that run through my head are below:
What type of server will I need?
How will I know if it can run Python?
How does the server know that I want to execute a certain script, while upon a user entering a my website's homepage URL, land at the home screen?
I've also read up on "middle layers" such as 'CGI' - what does this accomplish?
Is setting up a server reinventing the wheel?
enter code here
Is there already a service out there that does what I'm looking for?
I've accomplished a similar project overnight with a Python web framework called Django, simply by following their official tutorial: https://docs.djangoproject.com/en/1.7/intro/tutorial01/
Django abstracts away all the web stuff for you and there's plenty of documentation on deploying it in various environments. With such deadlines I suggest you to just follow the tutorial above and eventually adapt the example to your use case testing it on Django's built-in web server, then follow a guide on deploying Django projects in your production environment.
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.
I am right now working in a project where I have two GAE servers. One for development, and the other one for production.
So I needed to access the datastore to run some queries because I need some high level information about the entities we have. The way I did on the development server was by the " URL/_ah/admin ", and there I used the Interactive Console to run my queries in the server.
But the reality is obviously that I need to run that queries in my production server, I tried to acces there the same way by "myapp.appspot.com/admin/interactive" but I am getting a "Page not found", I cant acces either with " URL/_ah/admin ".
So I looking for the easiest way for me to be able to run that queries, by now it seems that I have found two posible ways that I would like to check with you.
First, it seems that I could active that Interactive Console by:
- url: /admin/.*
script: google.appengine.ext.admin.application
login: admin
And then I would have acces on the URL "myapp.appspot.com/admin/interactive". Is that correct?
Second, I have also read about the remote_api and using the remote_shell as an Interactive Console with the server. Would that be harder? Can someone of you link me a guide to do that?
I havent tried anything yet, because I must be sure of what I am going to do since this is a live project.
Thanks a lot,
Jose.
This is only made for the development server.
You can find all the code that runs it in the source and then use them as custom admin console pages.
For example, in app.yaml, place
admin_console:
pages:
- name: Interactive Console
url: /admin/interactive
and for the URI
handlers:
- url: /admin/interactive|/admin/interactive/execute
script: google.appengine.ext.admin.application
login: admin
since the interactive page relies on a POST handler in execute.
I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities.
Recently I come across a problem. If I create a form in flex and then communicate with the django server, I can't see any debugging info (when the exception happens in django).
Not sure, if there is a way to get the debugging info, because it is not accessible in command line (no error output), or in firebug....
Also I tried to create a quick html form, and post same data as I send from flex form, but it's a bit of pain to be honest.
Will be happy to listen how do you solve the problem
I've used firebug to debug the flex side of things. But I've been using json or XML for communication between the two. Since flash uses the browser to do the network stuff, the request should be visible in the net tab of firebug.
To debug the django side of things, you have a few options.
If you're using the django dev server, you can add print statements to find out what's going on.
You can write a unit test to see if the django side of things is doing what you expect it to, given known data.
You can use the pyDev debugger to run the django dev server and step through your code.
I use a combination of these to debug my code.