Strategic error on Python/Flask deploy - python-2.7

I'm new to web development and deployment however I developed a web site using Python 2.7 and Flask. I can't get the site to load when the user hits the site. When testing on the server using SSH the program starts like it did on my development PC but does not render the first template and shows this error: WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
In researching that error I found an article that says Flask is not meant for a multi-user public web environment. Further investigation said: If you want to run Flask in production, be sure to use a production-ready web server like Nginx, and let your app be handled by a WSGI application server like Gunicorn.
I think what this is telling me is:
Find a provider that supports Nginx.
Install Gunicorn and then configure it to run on that host.
Doing that should allow my program to run on the host server and be accessible to the world.
Would folks with experience with Python/Flask web apps please confirm the direction I should be heading as I can't afford to go down the wrong path again.

Related

How to run a Django's application server on a VPS server

I have an application that should run via VPS terminal-based so that the web app can be online permanently.
The command: python manage.py runserver 173.249.8.237:8000 should be executed via the VPS terminal because when I use putty via my laptop, whenever I switch off my putty software via my laptop, the application won't be accessible.
Please, suggest to me a way open a terminal in order to run the Django application server.
Or, is there any method that can allow me to my Django web application on VPS?
Thanks in advence
Don't do that.
runserver according Django 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.)
You need to configure your Django application to run in production environments. You change choose docker for that.
Or simple running with gunicorn.
Access your VPS through SSH or Putty.
Copy your application code inside VPS
Configure your application to run with gunicorn or docker
Access your VPS address in your browser.
And turn of the DEBUG mode, by setting DEBUG=False

cannot access a development server on a server im ssh'd into

I am deploying a django app from a Centos server. When i do a python3.6 manage.py runserver 8000 command it starts a development server no problem. I am not able to access this page from my local computer to test it.
so the steps i take are: i ssh into the server by doing ssh <user>#url.com and then run the dev server with the above command. I then go to the browser on my laptop and type url.com:8000 and will come up with Unable to connect
I also have this problem when running my apache server for production. i would have no problems putting up the server on the server im ssh'd into but cannot access the webpage.
I know this is very little information to go on but does this sound like a server side issue at url.com? Should i be contacting the administrators with this, or is this something on my end possibly?
Maybe i need to configure the address my settings.py in my django app?
You probably want to run it so it listens on any interface. From the documentation:
Note that the default IP address, 127.0.0.1, is not accessible from
other machines on your network. To make your development server
viewable to other machines on the network, use its own IP address
(e.g. 192.168.2.1) or 0.0.0.0 or :: (with IPv6 enabled).
By example, you should start the server with
python3.6 manage.py runserver 0.0.0.0:8000
In general, it is probably not wise to keep such a thing running on the web, particularly with debug on. From the same documentation link:
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.)

Django's development server on Ubuntu not accessible via browser, only via -curl

I am trying to set up a Django website on an Ubuntu server hosted on DigitalOcean.
After following the step-by-step DigitalOcean tutorial here: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
I remain stuck as I cannot seem to access Django's development server launched on 0.0.0:8000 with the browser of my local machine. However, I do have a response using -curl from the server's bash terminal. So it seems it can only be accessed from the server itself. Django does not return any error while launching the development server. It lists successful connections (code 200) every time I access it via -curl, but does not show anything when I try to access it via my external browser, as if it is actually not being acecssed.
What I did:
followed this tutorial step-by-step until the launch of Django's development server,
disabled Ubuntu's firewall and no DO firewall is used
added '*' in ALLOWED_HOSTS in settings.py
Any ideas? Thank you very much!

The page load, but didn't show up the content

I'm trying to connect to the server with IP_address_server:8000, but the page load without ever wanting to connect.
In fact, I start a Django project, and I did python3 manage.py runserver 0.0.0.0:8000. In the project settings.py, I've included IP_address_server in ALLOWED_HOSTS (on the server), but I got the same issue.
Could anyone be able to tell me what could be the problem?
First, if you are (really meant to)hosting your django application on cloud, you should not use django's inbuild server, that is manage.py runserver. Check official docs, quoting here:
Now’s a good time to note: don’t use this server in anything resembling a production environment. It’s intended only for use while developing. (We’re in the business of making Web frameworks, not Web servers.)
Now, if I am wrong and your application is indeed hosted on Nginx/apache, check server logs, for Nginx, /var/log/nginx/, for Apache, /var/log/apache2/.
If not, you can follow some of Django deployment guides, eg here or here

Why is flask app throwing an error in cpanel

Can anyone let me know how to deploy a flask app on a personal website using CPanel
I have tried running it through the virtualenv but did not work
Flask is a micro framework that runs in a Python instance, and not as a set of files that are served from a web server, like HTML or PHP. Most likely you will need another hosting provider that hosts web applications like Heroku or use a VPS instead.
On the other hand, most shared hosting providers do not allow you to install custom libraries that need to be compiled.