I have used the Swagger Editor to create a REST API and I have requested the server code download for Python Flask. I'm trying to deploy this out to Google Cloud Platform (I think that's the latest name? Or is it still GAE?) but I need to fill in some gaps.
I know the Swagger code works because I have deployed it locally without any issues. However, it uses the connexion library instead of Flask outright.
I'm mostly lost on how I can incorporate an app.yaml file for GCP and the right entrypoints within the generated code. In addition, I know that the generated code declares it's own app server which I don't think you need to do for GCP. Here's my current app.yaml
application: some-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: yes
entrypoint: python app.py
libraries:
- name: connexion
version: "latest"
And here's my app.py
import connexion
if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'this is my API'})
app.run(port=8080)
The primary error I'm getting now is
google.appengine.api.yaml_errors.EventError: the library "connexion" is not supported
I have a feeling that's because of the way I am declaring an app server in my app.py - it probably shouldn't be needed. How would I modify this file to still use my Swagger code but run on GCP?
You seem to have some inconsistencies in your file, it's unclear if you intended it to be a standard environment app.yaml
file or a flexible environment one. I can't tell as I'm unfamiliar with swagger and flask.
If it's supposed to be a standard environment one then:
entrypoint:
is not a supported config keywordconnexion
library is not one of the runtime-provided third-party libraries, so you can't request it (i.e. listing it in the libraries
section). You need to install it (vendor it in).
handlers
sectionProbably a good idea to go through Getting Started with Flask on App Engine Standard Environment
If, however, your goal was a flexible environment app.yaml
file then:
env: flex
and runtime: python
config in it(vm: true
and runtime: python27
in the original answer are now deprecated) libraries
section.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With