Skip to content Skip to sidebar Skip to footer

Flask Deployed With Twistd: Failed To Load Application: 'nonetype' Object Has No Attribute 'startswith'

I am trying to deploy my Twisted application using .tac files and twistd I tried to deploy it with the command line: twistd -y service.tac I have the error: ... application = getAp

Solution 1:

Your application import_name can't be identified properly in *.tac file. If you create flask application in *.py file and import it in *.tac it will work just fine.

But you also need another list of instructions for deploying Flask application via twistd. Minimal example looks like this:

from twisted.applicationimport internet, service
from twisted.web.serverimportSitefrom twisted.web.wsgiimportWSGIResourcefrom twisted.internetimport reactor

from my_flask_module import my_flask_app

application = service.Application('myapplication')
service = service.IServiceCollection(application)

flask_resource = WSGIResource(reactor, reactor.getThreadPool(), my_flask_app)
flask_site = Site(flask_resource)
internet.TCPServer(8000, flask_site).setServiceParent(service)

Post a Comment for "Flask Deployed With Twistd: Failed To Load Application: 'nonetype' Object Has No Attribute 'startswith'"