1

I'm having trouble deploying a FastAPI app on IIS.

This is the error that I get.

Error occurred:

Traceback (most recent call last):
    File "c:\programdata\anaconda3\lib\site-packages\wfastcgi.py", line 847, in main
        result = handler(record.params, response.start)
TypeError: __call__() missing 1 required positional argument: 'send'

Any ideas?

laplace
  • 656
  • 7
  • 15
  • 1
    Use HttpPlatformHandler, not `wfastcgi.py` please, https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019#configure-the-httpplatform-handler – Lex Li May 05 '21 at 06:42
  • If you want to run FastAPI in IIS, we can use IIS as a reverse proxy to run FastAPI: https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing – Ding Peng May 05 '21 at 08:23
  • In my opinion you likes me, please see this answer https://stackoverflow.com/questions/65292991/running-fastapi-under-iis/71126359#71126359 – INTz_ Feb 15 '22 at 12:32

1 Answers1

0

I solve this issue by

1- in cmd pip install a2wsgi

2- in main.py

  • A - from a2wsgi import ASGIMiddleware
  • B - in the end of your code write

wsgi_app = ASGIMiddleware(app)

like this

from a2wsgi import ASGIMiddleware
from fastapi import FastAPI


app = FastAPI()


@app.get("/")
async def view():
    return {"Hello":"World!"}

. . . . . .

wsgi_app = ASGIMiddleware(app)

3- in webconfig add

<add key="WSGI_HANDLER" value="main.wsgi_app" />
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 22 '22 at 22:06