Python Application URL - python

I created a Django Python application in localhost and setup virtualenv for running python application. I run this application from terminal and can access with this url- http://127.0.0.1:8000/ . On hosting time (server) how can i access this application using url?

I suggest you to check out this page of the django documentation if you haven't already: https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
Deployment of a web application is not as easy as running the python development server, that is extremely simpler and is discouraged to be used on a server by the django documentation itself.
On a theoretic point of view, the reason why you can't access remotely the development server is because it binds the server on local only access: to make it accessible from an external computer you need to bind it to listen on 0.0.0.0 instead of 127.0.0.1, then you will be able to reach it on example.com:8000 depending on what the server's domain is and what port you choose. To use 0.0.0.0 you call manage.py runserver like this:
./manage.py runserver 0.0.0.0:8000
but avoid to do it, and opt for a more robust deployment :)

If your trying to deploy your application for the first time, and you want to get a feel of accessing your app from url, try heroku, https://www.heroku.com/
Easy and you don't have to worry about setting up everything.

Related

How to make django globally available

How can I make my Django project accessible via internet?
When I execute the project in Windows OS by typing with a disabled firewall it works and reachable via the internet.
But in Linux OS it does not. I tried the same actions. Executed it by typing and made sure my firewall is disabled
python manage.py runserver 0.0.0.0:8000
The expected result is that project is accessible via the internet like in windows OS
you must deploy your app in one server. I recommend you pay for one VPS like digitalocean. And dont run you app with runserver. Runserver is only for development. Use one wsgi like gunicorn.
If you not want pay for this service. You can use heroku
https://devcenter.heroku.com/articles/deploying-python
I recommend use docker. Docker possibilite you development and deploy same envoriment

How do I update my web app features in the linux server? web app is build with Python, Flask, uwsgi and server nginx

I am new to Python development. I am building a test Python app and already deployed into a web server and accessing it through public IP. Now I have updated the source(that is added some more models and templates), Now I want my public IP under port 80 should show updated code.
How do I do this?
if you have used any sort of version control, it's just commit and push/pull to the server.
if not, you have to copy the code, paste it in the server, restart the application and it work's with new code.
best approach is make a service, deploy the code with git version control, run the service and you are good to go. service will start automatically in case of system-restart and such.

How to host Django 1.10 Web Application on WHM via cpanel?

I want to host my Django 1.10 web application on WHM(VPS). for that i have installed Django and another necessary tools on WHM(VPS) by ssh login. and i also have uploaded my Django application code through cpanel in public_html directory.
When i run python manage.py runserver <ip_address:8000> from ssh terminal, i am able to access that application. but when i close the ssh terminal, it terminates all the running process. so could not access application after that.
So, Is there any way that without running python manage.py script i can access Django application?
Any help would be highly appreciated.
Thank you.
Django comes with a built-in development server, it's not really meant to be used when deploying to a remote VPS.
There are some great resources to help you along, but what you're likely going to want to do is deploy your app on a stack using gunicorn or uwsgi as an application server and a web server like Nginx or apache 2 as a reverse proxy.
I personally use Nginx and uwsgi.
There are some great resources explaining how to deploy a Django server. Have a look at this one from digital ocean, it was a great help when I needed to set up a production server correctly: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04
best of luck with it!

Python (CherryPy) web app deployed locally, but not visible over intranet

I've created a Python web app using CherryPy, and have deployed in on my local machine.
When I try to view it from another computer in the house, nothing comes back.
However, if I create a simple html file, and deploy it with:
$ python -m SimpleHTTPServer
It is visible over the intranet.
I'm stumped as to why my app could work locally, but not be avalable over the intranet, given that there is not a connection problem between these machines, and that I can serve other content on the same port.
I have not used a configuration file, I'm using the default CherryPy settings.
The default settings likely bind to localhost, which is not publicly available. If you want CherryPy to run on a public interface, you'll have to direct it to do that. From this discussion I found:
cherrypy.config.update(
{'server.socket_host': '10.149.4.240' } ) # Pub IP
cherrypy.quickstart()
or
cherrypy.config.update(
{'server.socket_host': '0.0.0.0'} )
cherrypy.quickstart()
To bind to all interfaces.

Django + alwaysdata.com Noob Question

I'm learning Django and working on sample sites.. I registered at alwaysdata but am unable to view the site after I go 'manage.py runserver' in the SSH (this is after I've created the project and navigated to the appropriate directory, of course).
I appreciate any help.
Thanks
Have you taken a look at the wiki entry regarding the django dev server? Google translate seems to indicate that you need to request some ports open first, and that once you've got them assigned you can pass in one of those port numbers to runserver to run it on that port.
If you need the translated-to-English version, here's a link
I am also an alwaysdata customer. Daniel DiPaolo gave you the right links to get it working on ssh with the dev server. The google translation seems correct to me. You need to request a port range in order to use the dev server on ssh.
But this is intended only for debugging purpose and should run for a short while.
Here is how to deploy with fastCGI which is the regular way to deploy a Django site on alwaysdata.
http://wiki.alwaysdata.com/wiki/D%C3%A9ployer_une_application_Django.
Google give a decent translation
AlwaysData is running a forum at http://forum.alwaysdata.com/ mostly in French but questions in English are welcomed.
The devserver included with django is for testing purposes, only on your local machine and should not be used on a web host. From the docs:
DO NOT USE THIS SERVER IN A PRODUCTION
SETTING. It has not gone through
security audits or performance tests.
(And that's how it's gonna stay. We're
in the business of making Web
frameworks, not Web servers, so
improving this server to be able to
handle a production environment is
outside the scope of Django.)
If i have somehow misinterpreted your question, i apologise.
When you enter manage.py runserver you're running the development web server on the loopback interface (127.0.0.1). You could test this out by running wget 127.0.0.1 on the same server that the development web server is running.
If you want it to be on the internet so you could access it from outside that server, you'd have to specify your public ip. For example, to run the web development server on ip 1.1.1.1 and port 8080 (personally recommend using a non-standard port):
manage.py runserver 1.1.1.1:8080
To find out your public ip, try running ifconfig on SSH.
Also, you might have to check out the firewall settings with your ISP/server provider.

Categories

Resources