Django + alwaysdata.com Noob Question - python

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.

Related

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.

Need clarification on running python application over LAN [duplicate]

This question already has answers here:
Are a WSGI server and HTTP server required to serve a Flask app?
(3 answers)
Closed 5 years ago.
I am getting into Flask/Python model and it seems to be getting along fine in the initial stages. Is there a way to run python application as a web application on a simple desktop computer and use that app over LAN? If yes, what will be the process for that?
I mean, I understand that frameworks like flask/django/bottle run their own server instance which results in the execution of such web apps. In this way they are practically acting as IIS/Apache. Correct?
The reason for this question is that this app will be accessed by only 4-5 individuals & we all are a part of the same team.
If the number of users are going to be limited to 4-5, then django server might just be enough for you. You'll just need a router and devices with WiFi access or just an access to the router.
You can simply run your server as,
python3 manage.py runserver 0.0.0.0:8000
python or python3, depending on what you're using.
After this your django project would be visible on all the devices connected to your router, at the address,
Local-IP-Address-Of-Device-Runing-Django-Project:8000.
Note: Django is excellent during the development phase but it's not recommended for production use, or when users increase. see docs here
So I recommend that if number of users increase(increase in load), ideally you should switch to gunicorn with ngnix or apache server (gunicorn is easy and widely used for python apps. It usually works well ngnix as a reverse proxy; entrance point to your server). There are many tutorials for hosting your website using gunicorn with ngnix as a reverse proxy.
Hope this helps. Thanks.

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 Application URL

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.

A list of everything I need for running my app on a web server

What I want to know are actually 2 things.
Part 1:
I have a developed source code for an application in python that uses Django framework.
What I want is to be able to run the code on a developer machine and see the result. What do I need for it?
(my guesses):
Python development enironment (Eclipse/PyDev/Aptana Studio 3 seem to be the better ones for windows not sure linux yet),
I also have a postgre database already setup (I know there's a file where I have to specify connection information)
- something installed from django or would this be already included in the code that I have?
Part II:
I also want to make a dev server accessible through internet.
- this is the major part of the question and the most important. How do I publish the app?
- I have a linux machine that I would do this on, but unsure of all the things I need. Apache server?
To answer your questions:
What you need: A list of requirements and instructions to get started with Django is available here: http://djangobook.com/en/2.0/chapter02/.
Database: that chapter also includes a section on configuring access to your database, with a specific section on postgreSQL.
Dev server: To start a basic development server, see this tutorial section
Deploying django (production): For instructions on how to deploy Django for production, see chapter on deploying Django.
Publishing on internet: as for making your dev server accessible through the internet, ask on https://serverfault.com/. Make sure you provide more information about your network setup, what you've tried, what isn't working, etc. (Briefly, you need to make sure that the host you are running your server on is on a publicly accessible IP, or has port 80 forwarded to it from such a host. If in doubt, speak to your sys/network admin if you have one. Or use a django hosting service such as those listed on http://djangohosting.com)
IDE : Regarding IDE, it's down to personal preference. What you mentioned are fine and can run on Linux too.
As a first step, I suggest you follow the tutorial which guides you through the process of starting a development server and developing a basic app.
Even if your goal is to deploy an existing app, the tutorial will give you an idea of how the different components work together (apps, models, urls, templates, etc) which will help with debugging when something goes wrong with your deployment.
Good luck.
You need Python, Django, a WSGI container (e.g. mod_wsgi, uWSGI, Paste Deploy), and a database server. You make the Django project available as a WSGI app, bound to the appropriate interface on the machine.

Categories

Resources