Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api().add_resource() Don't work if running as Windows Service (win32serviceutil.ServiceFramework) #944

Open
WillianBR opened this issue May 18, 2022 · 1 comment

Comments

@WillianBR
Copy link

Folks,

I stumble on a weird scenario today.

I'm working on a small API Server, who will receive POST/PUT requests with service order numbers (JSON Array).

I did the home work and it work just fine while I was running as stand alone application.

But after I start the Flask app inside a Windows Service class (inherited from win32serviceutil.ServiceFramework), it fail all the time.

Any endpoint added into API() fail, but the ones added directly on Flask() app work 100% fine.

The basic block is:

app = Flask(__name__)
api = API()
...
api.add_resource(ReceiverIntNotification, '/api/<os_id>')
api.init_app(app)

But if I start it as service the call to "http://server:port/api/os999999", it's catched by Flask block:

  @app.errorhandler(404)
  def OnPageNotFound(error):

I don't wanna use the NSSM to run my service. I wanna get fine graine control over my service.

The cURL header output give me:

< HTTP/1.1 404 NOT FOUND
< Server: Werkzeug/2.1.2 Python/3.10.4
< Date: Wed, 18 May 2022 20:25:22 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 41
< Connection: close
<

I tryed to list the endpoints (app.url_map.iter_rules()), but nothing is showed off.

By the way, Does anyone know how to list the endpoints of API()?

My pip freeze output is:

aniso8601==9.0.1
argcomplete==1.12.3
atomicwrites==1.4.0
attrs==21.4.0
bottle==0.12.18
certifi==2021.10.8
chardet==3.0.4
click==8.1.3
colorama==0.4.4
Flask==2.1.2
Flask-RESTful==0.3.9
idna==2.10
itsdangerous==2.1.2
Jinja2==3.1.2
loguru==0.6.0
MarkupSafe==2.1.1
more-itertools==8.13.0
packaging==21.3
pluggy==0.13.1
prettytable==0.7.2
py==1.11.0
PyHamcrest==2.0.2
pymongo==3.11.0
pyparsing==3.0.9
pytest==5.4.3
pytz==2022.1
pywin32==304
requests==2.24.0
servicemanager==2.0.10
six==1.16.0
urllib3==1.25.11
wcwidth==0.2.5
Werkzeug==2.1.2
win32-setctime==1.1.0

Windows Server:

Windows Server 2016, 64bits

Anything out of API() object, work just good!

Does any one stubled on this issue?

Can anyone help me?

@WillianBR
Copy link
Author

P.S.: I digged the docs, but nothing until now!

https://flask-restful.readthedocs.io/en/latest/api.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant