shivas shivas - 5 months ago 119
Python Question

Running Python Flask rest api on Windows / IIS

What is the best option to run a Python Flask rest api service on a windows machine? Not on Azure

I have tried multiple options using fastcgi and httphandler and a windows service.

I want to know what other use to host a Python Flask rest api on a windows server in a production environment

Answer Source

If you want to just "run" a flask app on windows, then all you need is python. Install flask and you are good to go:

pip install flask

Once you have flask, you can write any script using it and just call it using python:

# hello_world.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

flask is WSGI compatible, so you can host this script locally by running python hello_world.py on the DOS prompt.

But if you talking about production hosting on a windows machine instead of linux, then I don't think its a good idea. Most popular options for WSGI hosting like uwsgi and gunicorn are linux only (unless you perform hackish workarounds like cygwin).