Giter VIP home page Giter VIP logo

Comments (14)

hjacobs avatar hjacobs commented on May 12, 2024

Definitely looks like something desirable, but actually I never used a WSGI server host such as Apache/mod_wsgi etc before. I simply use Connexion with gevent and packaged as Docker image.

from connexion.

iwsmith avatar iwsmith commented on May 12, 2024

Yeah this is what I ended up doing as well. So this issue isn't blocking/causing an issue, more of a "one day Connexion should probably do this" sort of thing. Maybe an enhancement instead of a bug? Some additional documentation on the matter wouldn't hurt though...

from connexion.

hjacobs avatar hjacobs commented on May 12, 2024

👍 I hope "somebody" (tm) with WSGI experience can step in here :-)

from connexion.

hjacobs avatar hjacobs commented on May 12, 2024

@iwsmith using uWSGI is actually quite easy (just needs to expose app.app as "application" for WSGI), check my example: https://github.com/hjacobs/connexion-example#using-connexion-with-a-wsgi-container

from connexion.

hjacobs avatar hjacobs commented on May 12, 2024

I will close this issue as the Flask WSGI application can readily be used in WSGI containers (see connexion-example).

from connexion.

iwsmith avatar iwsmith commented on May 12, 2024

I haven't had time/the need to look into this, but thanks for following up!

from connexion.

majoros avatar majoros commented on May 12, 2024

The following is all that's needed to get it working with wsgi

app = connexion.App(NAME)
application = app.app

from connexion.

hjacobs avatar hjacobs commented on May 12, 2024

👍

from connexion.

spearsem avatar spearsem commented on May 12, 2024

Has anyone looked into how this can work with gunicorn instead of uWSGI? This is quite an important tool for deploying Flask apps, so ensuring there is documentation for how to use with gunicorn might be a high priority.

from connexion.

sellers avatar sellers commented on May 12, 2024

What goes into the swagger yaml file for the module name? I can get this to work with invoking ./python.py but not with python python.py or via WSGI. I get the module object has no attribute XXX

from connexion.

FirefoxMetzger avatar FirefoxMetzger commented on May 12, 2024

@sellers are you using the flask / connexion swagger generator?
If so then that is because the generated __main__.py creates the app within main() which called within the if __name__ == "__main__" statement and as such the app will only be created if it's executed directly. WSGI (uwsgi or gunicorn) will instead load it as a module and not execute the if statement.
Edit (02-2018): I just realized how very over complicated above wording was. The reason it doesn't work is because app is created as a local variable of main() in the swagger generated code and not as a variable in the module's namespace.

In this case the solution would simply be to modify that file so the app (and application = app.app) is created as a variable in the module's namespace (e.g. by moving it outside of main()).

from connexion.

hjacobs avatar hjacobs commented on May 12, 2024

@FirefoxMetzger maybe do some upstream PR for the Swagger generator template to fix the issue?

from connexion.

profgiuseppe avatar profgiuseppe commented on May 12, 2024

#392 may be of interest if someone (like me) stumbles in this discussion.

from connexion.

aude avatar aude commented on May 12, 2024

This looks to work now. I can successfully run:

$ gunicorn main:app
[2020-07-02 13:38:08 +0000] [144535] [INFO] Starting gunicorn 20.0.4
[2020-07-02 13:38:08 +0000] [144535] [INFO] Listening at: http://127.0.0.1:8000 (144535)
[2020-07-02 13:38:08 +0000] [144535] [INFO] Using worker: sync
[2020-07-02 13:38:08 +0000] [144537] [INFO] Booting worker with pid: 144537

Maybe ideas from the original post was implemented.
https://github.com/zalando/connexion/blob/bed4b95205205861bd6014282d0f61d50231d3ac/connexion/apps/abstract.py#L242-L249
This code from a7af62f could indicate that.

from connexion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.