Connexion: [question] Connexion with Twisted

Created on 7 May 2017  路  3Comments  路  Source: zalando/connexion

Description

Does anyone have a mechanism for running Connexion with or under Twisted? There is documentation for running Flask itself under Twisted, but I'm not seeing an easy way to adapt this for Connexion ??

Most helpful comment

Sorry, answered my own question, here it is if anyone else is trying .. this solution depends on;
https://github.com/cravler/flask-twisted

#!/usr/bin/env python3

import connexion
from .encoder import JSONEncoder
from twisted.internet import reactor
from flask_twisted import Twisted

if __name__ == '__main__':
    app = connexion.App(__name__, specification_dir='./swagger/')
    app.app.json_encoder = JSONEncoder
    app.add_api('swagger.yaml', arguments={'title': 'Microservice API'})
    reactor.callLater(1, print, '<<Twisted is running>>')
    Twisted(app).run(port=8080)

All 3 comments

Sorry, answered my own question, here it is if anyone else is trying .. this solution depends on;
https://github.com/cravler/flask-twisted

#!/usr/bin/env python3

import connexion
from .encoder import JSONEncoder
from twisted.internet import reactor
from flask_twisted import Twisted

if __name__ == '__main__':
    app = connexion.App(__name__, specification_dir='./swagger/')
    app.app.json_encoder = JSONEncoder
    app.add_api('swagger.yaml', arguments={'title': 'Microservice API'})
    reactor.callLater(1, print, '<<Twisted is running>>')
    Twisted(app).run(port=8080)

@oddjobz thanks for the info!

Do you think it would be possible to integrate an additional Twisted based library in this setup? I'm thinking of invoking Scrapy based on request parameters and to return the crawler's results in the response.

Was this page helpful?
0 / 5 - 0 ratings