Running Django in IIS - python

I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?

Related

Dash/Flask - Deployment of an application on my own server

I am a newbie in web development, I am an energy engineering student trying to make a project, so I apologize if I say something weird.
I've made an application using Dash (python). And now, I would like to deploy that app in my server. I have a remote server (debian, adress.com, IP, opened ports: 80 and 443...) with my ssh public key and all the required stuff.
I have read all the official documentation in the plotly dash page, and also in flask's, but I dont understand very well the thing. I need either Heroku, OpenShift... And I dont understand very well how them work.
Could you please recommend me an easy tutorial (for dummies!) or give me advices/examples about the deployment? I would really apreciate I've searched the Internet a lot, but I can't figure it out.
You describe two options:
1. using your own server to host your app and
2. using a service which will host your app (heroku, etc.)
Using your own server to host your app
You need to decide for a web server, which is serving your page on your server. A host will not magically answer on any port. There is for example apache, nginx, etc... After having chosen one, you need to find a tutorial: how to run your flask app on [yourwebserver] or something like that.
Suppose you have chosen apache, you will find something like this:
https://jackhalpinblog.wordpress.com/2016/08/27/getting-your-python-3-flask-app-to-run-on-apache/
(In this case, you will have to figure out how to run your flask app with python3 instead of python2, if you are running debian)
When your page serves your page, you need an ssl certificate in order to make use of your domain. An easy way of doing this is https://letsencrypt.org/getting-started/ (there are probably other similar services)
Using a service, which will host your app for you (heroku, etc.)
Alternatively do not host you app on your own server, but on heroku, aws, gcd, etc., in my opinion this is much easier than hosting it on your own server. The documentation on hosting service websites is normally very good.
For heroku a good starting point would be here:
https://devcenter.heroku.com/articles/getting-started-with-python. Nevertheless the other services are easy to use as well, i just use this as an example.

How to deploy django website in ubuntu 18.04 + plesk + apache in digitalocean droplet

In my droplet is running several PHP websites, recently I tried to deploy a Django website that I build. But it's doesn't work properly.
I will explain the step that I did.
1, Pointed a Domain name to my droplet.
2, Added Domain name using Plesk Add Domain Option.
3, Uploaded the Django files to httpdocs by Plesk file manager.
4, Connected the server through ssh and type python manage.py runserver
0:8000
5, My Django Website is successfully running.
Here are the real issues occurs, We need to type exact port number to view the website every time. Eg:- **xyz.com:8000 **
As well as the Django webserver is down after sometimes.
I am newbie to Django all I have experience in deploying a PHP website. If my procedure is wrong please guide me to correct procedure.
Thanks in Advance.
Django Runserver is not a production one, it should be used only for development. That's why you need to explicitly type in the port and it sometimes go down because of code reload or other triggers.
Check Gunicorn for example, as a production server for Django applications. (there are other options also)
I suggest following this guide. Covers initial setup of django with gunicorn and nginx which is essential for deployment, you don't have to add the port to access the site. It doesn't cover how to add the domain but it seems you already know how to add the domain though.

Django Runserver - moving from running locally

I want to move from local host to a static IP address (I have it already) with specific DNS name, I'm confused on how to do that? and how to make my app working just by accessing this IP or DNS names from a web browser? Should any machine install all the requirements like Python, Django, IDE etc? not sure how this will happen. I appreciate the help
Edit: I tried this:
runserver 0.0.0.0:80
from the manage.py, that should allow any IP to access my page, however, is that the good way to do it?? Also, how to specify the DNS, and I want a domain name instead of an IP to access the page.
I'm fairly new to Django but I got my website up and running on PythonAnywhere. It was easy to setup and they provide domain name as [username].pythonanywhere.com. I followed this tutorial in order to set it up: http://tutorial.djangogirls.org/en/deploy/
The tutorial does it by putting the code up on Github then going to PythonAnywhere and doing a git clone. However, PythonAnywhere allows you to upload your code directly to their servers. After you upload the code you can use a virtual command prompt to pip install the packages you need, such as Django.
I hope this helps. Let me know if you have any questions.

How to integrate django with WindowsServer 2012?

I have a Python3 website on IIS8 server and WindowsServer2012 and would like to add django to it. I have started learning django and made some small examplaes on my localhost and now want to integrate django into the IIS.
It is important to note that I just want to see that it works on my IIS and then turn it off, so that I can move all the site to django on localhost, while the current site is still functioning correctly.
I got confused regarding different ways. Where would be a good starting point for this integration (note, this is Windows Server 2012)?

google code + temp server?

We are starting a new project to develop a website using django. We have created a project on google code. We would like to be able to occasionally show the progress of the site to some people, without having to purchase a real server.
We are all modifying the project through eclipse and SVN. What's the best way to create a runserver type thing but allow othes to access over the internet temporarily?
thanks
One way is to run Django development server to bind on multiple interfaces:
python manage.py runserver 0.0.0.0:8000
Or specify a IP of the interface to bind to, for example this would only listen on the interface who's IP is 192.168.1.100:
python manage.py runserver 192.168.1.100:8000
But Django development server is single threaded and thus will not work good with concurrent requests.
I would advise setting up a development preview on shared hosting or something, or even locally, with a proper web server (such as Apache or ngnix).
If you do it locally just portforward your traffic from router to your local installation, if you don't have static IP you can use a service such as DynDns or No-ip.
This subject has been covered several times on Stackoverflow, feel free to search for other ideas.

Categories