michael-lazar / flask-gopher

A Flask extension to support the Gopher protocol
GNU General Public License v3.0
74 stars 6 forks source link

Using WSGI server (like Gunicorn) with Flask-Gopher #13

Open tyteen4a03 opened 1 year ago

tyteen4a03 commented 1 year ago

Hi, very nice library. Could you confirm whether it's possible to serve this application behind a WSGI server, and how?

michael-lazar commented 1 year ago

Hi,

Because WSGI servers only know how to handle HTTP traffic, you need to teach them to "speak" gopher. For the built-in Flask server (i.e. werkzeug), this is what I am doing with the GopherRequestHandler class.

https://github.com/michael-lazar/flask-gopher/blob/master/flask_gopher/flask_gopher.py#L591

Werkzeug is nice because it allows you to override the request handling with a simple python class. For production-grade servers like gunicorn I would guess that it's not so simple, but I haven't really looked into it.