4

Pulling my hair out! I am trying to deploy a Python FLask application to AWS Elastic Beanstalk and I am getting the error

Target WSGI script '/opt/python/current/app/application.py' does not contain WSGI application 'application'

The web page is just returning a 500 Server error

the content of my application.py is as follows:

#!/usr/bin/env python3
import connexion

if __name__ == '__main__':
    application = connexion.App(__name__, specification_dir='./swagger/')
    application.add_api('swagger.yaml', arguments={'title': 'This is a basic API fascade to theprotptype development robot. The API front-ends the communication with an MQTT pub/sub topic, which uses the Amazon Web Services IoT service.'})
    application.run()

Runs fine locally, but no good when I upload to AWS. I have changed the name from app.py to application.py and changed the app = to application = but no change

Don't know where to go next :(

user2997982
  • 526
  • 5
  • 8

1 Answers1

0

Try to move the line if __name__ == '__main__' after application=..., because the launcher may import your script instead of exec it. In that case __name__ will not be defined as __main__. See this page for better example.

application = connexion.App(__name__, specification_dir='./swagger/')
application.add_api('swagger.yaml', arguments={'title': 'This is a basic API fascade to theprotptype development robot. The API front-ends the communication with an MQTT pub/sub topic, which uses the Amazon Web Services IoT service.'})
if __name__ == '__main__':
    application.run()
gdlmx
  • 6,479
  • 1
  • 21
  • 39
  • Thanks, that moved it forward, now it passes that and fails with 'AttributeError: 'module' object has no attribute 'default_controller'' :) :( – user2997982 Jun 08 '16 at 00:00
  • Seems that your local packages have different version with those on the AWS. Check the version number of those related packages. – gdlmx Jun 08 '16 at 00:07