• Now all data be ready for publish, We had made our blog alive now. Haha.

  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…

Can I serve multiple clients using just Flask app.run() as standalone?- Stack Overflow

Python PingBook 1 months ago (10-23) 13 0


I know I can link Flask with Apache or other web servers. But, I was thinking of running Flask as a standalone server serving multiple clients simultaneously.

Is this possible? Do I have to handle spawning multiple threads and managing them?


flask.Flask.run accepts additional keyword arguments (**options) that it forwards to werkzeug.serving.run_simple – two of those arguments are threaded (a boolean) and processes (which you can set to a number greater than one to have werkzeug spawn more than one process to handle requests).

threaded defaults to True as of Flask 1.0, so for the latest versions of Flask, the default development server will be able to serve multiple clients simultaneously by default. For older versions of Flask, you can explicitly pass threaded=True to enable this behaviour.

For example, you can do

if __name__ == ‘__main__’:

to handle multiple clients using threads in a way compatible with old Flask versions, or

if __name__ == ‘__main__’:
app.run(threaded=False, processes=3)

to tell Werkzeug to spawn three processes to handle incoming requests, or just

if __name__ == ‘__main__’:

to handle multiple clients using threads if you know that you will be using Flask 1.0 or later.

That being said, Werkzeug’s serving.run_simple wraps the standard library’s wsgiref package – and that package contains a reference implementation of WSGI, not a production-ready web server. If you are going to use Flask in production (assuming that “production” is not a low-traffic internal application with no more than 10 concurrent users) make sure to stand it up behind a real web server (see the section of Flask’s docs entitled Deployment Options for some suggested methods).

Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:Can I serve multiple clients using just Flask app.run() as standalone?- Stack Overflow
LIKE (0)
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website