Python App on Apache2 access via domain - python

I am running a python app on port 8080 in a subdirectory on my apache2 webspace on my ubuntu server. I can access this application via server ip and port 8080. I got a domain which refers to my website. I want to access this python app via domain/subdirectory. How can i do this?

Related

unable to connect to docker container python flask app on a windows server 2016

I have a simple Python Flask based application in a docker image and I created a container with port mapping
docker run --name MypyFlskApp -p 5010:5000 flask-crud-rest-app
when i try to access MypyFlskApp container from host machine ("http://127.0.0.1:5010") i am getting error "Unable to connect to the remote server" but when i find container IP(http://172.19.247.234:5000) and tried the same then i get the response.
not sure why the port mapping is not working.
from host machine instead of 127.0.0.1 ( localhost) i have used VM IP address then my PythonFlask App started responding. Not sure why it is not able to access with 127.0.0.1(localhost)

Why does Flask use port 5000 locally and 80 when deployed?

I have been testing my Flask app locally and then deploying it on an AWS EC2 instance. Where is the default port defined? If I don't specify any port, it uses port 5000 locally; when deployed it uses port 80. Is it defined in the Flask code or is it part of the web server settings?
Flask's (Werkzeug's) dev server defaults to port 5000 if no port is specified. This is because binding to ports below 1024 requires elevated permissions.
You are not (or if you are, you shouldn't be) using the dev server in production, you're using a real WSGI server and HTTP server, such as uWSGI and Nginx, or Amazon's WSGI handler. The web server, independent of Flask, binds to port 80.

Running Flask with Gunicorn On Raspberry Pie

I'm trying to run my flask app with gunicorn on my Raspberry pi. I've set up my router to port forward the localhost:5000. This works well when I run my flask app via python manage.py runserver. I can use my browser from any device and type http://**.**.***.***:5000/ and it will load my flask application. However when I try and run the app via gunicorn I receive an error connecting page. I run the the gunicorn exactly like the flask documentation says to. If I check gunicorn's logs I can see the html being rendered. Here's the kicker, when I run the app with gunicorn locally (gunicorn -w 2 -b localhost:5000 my_app:app), it works just fine. I have optimum online, my router setting are as followed...
protocol -> all
port -> 5000
forward port to -> same as incoming port
host -> raspberrypi
locate device by -> ipaddress
Like I said these settings work just fine from my pi when I use python's built in wsgi server. Gunicorn works just fine on when I run it locally and I can see my app when I type localhost:5000 in the browser, it's just when I set it up on my pi and try to access the page with the external IP, if I don't use gunicorn the external IP works just fine. I can't figure it out. Any ideas?
You need to have Gunicorn listen on 0.0.0.0 (all network interfaces). This then means it will be listening on an externally accessible IP address.
There is more information on the difference between localhost and 0.0.0.0 in this post on ServerFault.

Accessing bottle server running on virtual machine

I've deployed a bottle application on Windows 2012 server deployed on AWS. I've configured the bottle server to run on 0.0.0.0 using run(host='0.0.0.0', port=9000).
Now, when I try to access the application from browser in my local machine, I get a "could not connect to ...." error. How do I start the bottle server on the VM?
Thanks.

Cannot access django app through ip address while accessing it through localhost

I have a django app on my local computer. I can access the application from a browser by using the url: http://localhost:8000/myapp/
But I cannot access the application by using the ip of the host computer: http://193.140.209.49:8000/myapp/ I get a 404 error.
What should I do? Any suggestions?
I assume you're using the development server. If so, then you need to specifically bind to your external IP for the server to be available there. Try this command:
./manage.py runserver 193.140.209.49:8000

Categories