I have generated a simple API server example using swaggerhub, and downloaded python-flask generated server locally.
Unfortunately, it seems to not work at all. Every time I try to access the indicated url, that is
http://localhost:8080/data/2.5//ui/
it returns me a 404 error.
I've tried all the solutions reported on:
Python connexion not displaying Swagger UI
but with no success. What am I missing?
A very simple detail that made all work: after executing pip install 'connexion[swagger-ui]' and pip install pathlib swagger_ui_bundle (though I am not sure the last is strictly needed...), the server worked only with an invalidate cache and restart command on PyCharm.
Related
Has anyone succesfully implemented flask-saml using Windows as dev environment, Python 3.6 and Flask 1.0.2?
I was given the link to the SAML METADATA XML file by our organisation and had it configured on my flask app.
app.config.update({
'SECRET_KEY': 'changethiskeylaterthisisoursecretkey',
'SAML_METADATA_URL': 'https://<url>/FederationMetadata.xml',
})
flask_saml.FlaskSAML(app)
According to the documentation this extension will setup the following routes:
/saml/logout/: Log out from the application. This is where users go
if they click on a “Logout” button.
/saml/sso/: Log in through SAML.
/saml/acs/: After /saml/sso/ has sent you to your IdP it sends you
back to this path. Also your IdP might provide direct login without
needing the /saml/sso/ route.
When I go to one of the routes http://localhost:5000/saml/sso/ I get the error below
saml2.sigver.SigverError saml2.sigver.SigverError: Cannot find
['xmlsec.exe', 'xmlsec1.exe']
I then went to this site https://github.com/mehcode/python-xmlsec/releases/tag/1.3.5 to get xmlsec and install it. However, I'm still getting the same issue.
Here is a screenshot of how I installed xmlsec
where does not seem to find the xmlsec.exe
documentationis asking to have xmlsec1 pre-installed. What you installed is a python binding to xmlsec1.
Get a windows build of xmlsec1 from here or build it from source
And make it available in the PATH.
xmlsec won't work properly in windows, better use Linux environment
Type the below command before giving pip install xmlsec
sudo apt-get install xmlsec1
I've built a Python/Flask based REST API using the connexion module. This working well as defining the REST API with with swagger.yml file works very well. The application is running, but when I navigate to /ui all I get in my browser is this:
I haven't disabled the UI, so I'm not sure what's going on and why the UI isn't being displayed. My application doesn't have a /static folder (it's only an API), so the app isn't serving any static files, not sure if that's related to the problem or not.
Any suggestions, pointers or hints about what I'm doing wrong would be most appreciated!
Here is a simplified example of my code:
# 3rd party libraries
from flask_cors import CORS
import connexion
def create_app(config_key, instance_config=None):
# create the connexion instance
connex_app = connexion.FlaskApp(__name__, specification_dir='./files/swagger/')
connex_app.server = 'gevent'
# get the Flask app instance
app = connex_app.app
# configure the application
app.config.from_object(config_key)
# add CORS support to application
CORS(app)
# define the API with the SWAGGER API definition YAML file
connex_app.add_api('line_controller_api.yml',
base_path='{url_prefix}'.format(url_prefix=app.config.get('URL_PREFIX', '/')),
resolver=AppResolver())
return connex_app
def production_app(instance_config=None):
app = create_app('api_config.ProductionConfig', instance_config)
return app
if __name__ == '__main__':
app = create_app('api_config.DevelopmentConfig')
port = 5001
logger.info('Line Controller API running on port %s', port)
app.run(host='0.0.0.0', port=port)
Thanks in advance,
Doug
connexion from 2.0.1 version onward don't have swagger-ui bundled inside it. You have install it explicitly using the below command (note the quotes)
pip install 'connexion[swagger-ui]'
Once you install it. swagger will work with connexion. In the earlier version swagger used to work with /ui added to your url at the end http(s)://host:port
But in 2.0.x onward use http(s)://host:port/<basepath>/ui
My stackoverflow reputation is too low for me to comment on Ashraff Ali Wahab's answer above but I just found out that I can edit it myself. Suffice it to say that it fixed the problem for me after I understood that the shell syntax, as presented, is wrong which was pointed out by Pablo Marin-Garcia. This is the shell syntax you need in Unix/Linux to properly install the swagger-ui plugin:
pip install 'connexion[swagger-ui]'
Any matched quotes will do. Note well that without the quotes, the pip command will run successfully but it won't install the swagger-ui component as you expect it to. Furthermore, I spent a lot of time scratching my head on this one because I did this in a virtualenv. I also searched the virtualenv for the swagger-ui component with find and I found some stub installed. So, if you are new to python or you are in a hurry, this can be easy to miss.
At the end of the day, I decided to add a local_requirement.txt file listing the correct version of Werzueg, connexion, and "connexion[swagger-ui]" which I install before using the stock requirements.txt because it seems like the Flask API code generated by the SmartBear tools is a little dated.
I had the same problem. I solved it with
pip install pathlib swagger_ui_bundle
It's caused by missing trailing slash. Just add slash at the end of your url and it will work.
Related issue https://github.com/zalando/connexion/issues/346.
It is really weird that after clicking run button, it does nothing and also no log and show a clock sign on the first column.
It works normally before. However, after I messed up my python environment, the google coursebuilder can't run web application. That's my guessing. When I run which python.it only shows:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
These let me feel like I have no way to solve it!Are there anyone who came across this problem before? Any ideas or suggestions?
Updated: I follow suggestions to use command line to run web application on GAE. It reminds me here:
Update: The error message shows that GAE can't get the allocated port and domain. The reason why it happens is that when I use command line to run the web application, I also open GAE GUI to run a web app with the same port number.
So the way to solve it is to close the GAE GUI and free the port. Or we also could designate another kind of port number with command line.(--port=XXXX and --admin_port=YYYY). Or take a look at the doc:
Again thanks for the help of Mihail R!
The OP had multiple issues with GAE setup which were resolved by simply reinstalling the GAE Launcher and making sure the app was first copied into Applications from the .dmg file, then ran from the Applications instead of from inside the .dmg file, and appropriate permissions were suppose to be given so that GAE Launcher created the symlinks it needed to work properly.
More instructions on proper GAE SDK installation can be found here: https://cloud.google.com/appengine/downloads after clicking on the needed SDK and then the OS the SDK will be installed on.
I've installed succesfully https://github.com/bradwhittington/django-templated-email.git, and it works smoothly on my local server, but, when I upload my app to a heroku repo that I have, when it get's to the sending email, the browser shows internal server error.
I think this is because it tries to read code from where "pip" installed the package, and that data path doesn't exists on heroku.
What I need to know:
How can I make it to work in my heroku server?
Thanks a lot!
Have you specified the below in your requirements.txt file for pip to know where to install it from?
The below points to the latest commit. If the developer has packaged the file as a egg, you can use that too.
git+git://github.com/bradwhittington/django-templated-email.git/62a291004cb21e50409b276bcbd79ae9808aace9
So if the missing package is the reason for your error, adding the above to requirements.txt should fix it
I've downloaded google_appengine version 1.3.1. Using some web tutorials, I've created basic django 1.1.1 application. Using appcfg I managed to deploy it on GAE and it works. The problem is, that application doesn't want to work on dev_appengine.py developement server.
Whenever I run the app GAE local server is returning HTTP 200 without any content. If I set basic environement and run main.py manually, then the page is properly returned on stdout.
I've also created very basic helloworld application, and this one is working ok on the devel server.
Do you have any idea, how can I debug the devel server? Option -d doesn't give any usefull insight at all.
I had module nammed same way as the default GAE launcher (main/ and main.py). After renaming the launcher everything works great.