Without server is it possible to run flask? [duplicate] - flask

This question already has answers here:
Are a WSGI server and HTTP server required to serve a Flask app?
(3 answers)
Closed 12 months ago.
I have a flask application, and I want to run this application in production. Is it possible to do this without your own server and if yes where it is possible?

Yes, You can run the flask application through your own webserver such as Apache2 or Nginx hosted in your own server.
Check this out for more info
https://flask.palletsprojects.com/en/2.0.x/deploying/

Related

Flask Webserver on Amazon Linux 2 - This site can’t be reached on browser [duplicate]

This question already has answers here:
Are a WSGI server and HTTP server required to serve a Flask app?
(3 answers)
Closed 17 days ago.
I have started a Flask Webserver on an Amazon Linux 2 EC2 instances
(venv) [ec2-user#ip-10-0-1-63 microblog]$ flask run
* Serving Flask app 'microblog.py'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
When i try to access the Web either via the below Public V4 DNS or Public V4 IP i get "Site cannot be reached"
http://34.228.161.61:5000
http://34.228.161.61:5000/index
https://ec2-34-228-161-61.compute-1.amazonaws.com:5000
https://ec2-34-228-161-61.compute-1.amazonaws.com:5000/index
I have successfully launched an Apache Web Server into the same EC2 & VPC instances and have no issues.
Also running curl from the same server i launched flask returns the contents
[ec2-user#ip-10-0-1-63 ~]$ curl http://localhost:7999
Hello, World![ec2-user#ip-10-0-1-63 ~]$
(tried a range of other ports also)
Any clues on what to do to get it working from my Chrome/Safari browser?
Tried so far
Ensured EC2 was talking to the web
Ensured VPC had route to the public internet
Ensured other webservers could be launched successfully from the same EC2 instance
Might be your application is not allowed for the outside world (0.0.0.0). Please check the running port in your system. You can use the below command to check:
sudo netstat -tulpn | grep LISTEN
check if 0.0.0.0: in your case, 0.0.0.0:5000 is showing in output or not.
Then try to run with below command:
flask run --host=0.0.0.0
Let me know, if that works. #Cloudkaramchari

Django Server Error: port is already in use, docker [duplicate]

This question already has answers here:
Docker & Postgres: Failed to bind tcp 0.0.0.0:5432 address already in use
(11 answers)
Closed 9 months ago.
When working with Docker and Django setup Initially sometime we will getting this error port 5432 already in use or TCP/IP not able to make connection. How to resolve this issue please find below.
This issue will happen because of two cases :
By suddenly stop or restart the system without closing the docker or DB to resolve it kill all PID ID by running this command kill -9 PID and kill all PID
Second issue was happening due to already in our system another Docker is present with same configuration then we have to change its name. along with it dont forgot to Inssert this line into settings.py DOMAIN_URL = config("DOMAIN_URL", "http://localhost:8000/") or DOMAIN_URL = "http://localhost:8000/"

How to share localhost port over local network [duplicate]

This question already has answers here:
Making django server accessible in LAN
(4 answers)
Closed 1 year ago.
I created webpage on local server with django framework (python). I have acces to it under address http://localhost:8000/. Now I want to share it over local network. I try to do it with Windows firewall Inbound/outbound rules, but it seems either I do something wrong or it's not enough.
To access a Django project running on a local network, you have to runserver with 0.0.0.0 as IP
python manage.py runserver 0.0.0.0:8000
and then set
ALLOWED_HOSTS = ["localhost", "yours_host_ip_aaddress"]
that should work if your firewall allows!
I am not sure how to suggest a duplicate question, but seems your question have an answer here. Basically, you need to ask the django program to accept connection from the outside world by
python manage.py runserver 0.0.0.0:8000

Request Line is too large (8192 > 4094) [duplicate]

This question already has an answer here:
How to set gunicorn limit_request_line parameter over 8190?
(1 answer)
Closed 1 year ago.
I am using nginx and gunicorn to deploy my django project, when I use GET funcation posted data to server I get the error:
Bad Request
Request Line is too large (8192 > 4094)
On nginx.conf I have:
client_max_body_size 100g;
client_header_buffer_size 512k;
large_client_header_buffers 4 512k;
Many methods on the Internet are changing "large_client_header_buffers" from 4 512k; but didn't fix the problem.
Any help or explanation is welcome! Thank you.
it is gunicorn issue, not Nginx
you can change the limit
--limit-request-line
https://docs.gunicorn.org/en/stable/settings.html#limit-request-line

Trouble allowing external public access to my webserver [duplicate]

This question already has answers here:
Configure Flask dev server to be visible across the network
(17 answers)
Closed 5 years ago.
I am attempting to setup a Web Server in my home using an old laptop. Here is what I have done:
TCP and UDP tested
CentOS 7 installed
opened port 80 and 8000 with firewall-cmd (confirmed open as I am able to access my Web Server within my own LAN)
opened port 80 and 8000 with my ATT Uverse Router (confirmed open with yougetsignal.com)
I am running a Python Flask application I have tried it on both port 80 and 8000.
I am able to connect to the flask app within my own LAN using the local IP but cannot connect externally by using my public IP.
Note: I am able to connect to it externally by setting the web server to DMZPlus mode (opening all ports) in my router, but it is very insecure.
Can someone please tell me what I am missing?
Thanks in advance.
What is the flask server listening on? Is it bound to 0.0.0.0?
Check the Externally Visible Server Section on this page.
http://flask.pocoo.org/docs/0.12/quickstart/