-
-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[question] How to serve static files ? #441
Comments
You can use the normal Flask tools to service static files ( |
@fabito is this answering your question? |
May a |
@webwurst yes, the Cookbook section sounds good. Willing to do a PR? |
So how is this done anyhow? I'm using connexion with swagger and I have the following
but neither |
For anyone who comes across this issue from google: api.py:
|
@felipemullen what did you add in your swagger.yaml to allow file send? Do you have an example, where you add the go_home() to the router of flask? |
@jonasman I added the following, to allow me to server html pages, to my
And then in the
|
For posterity, I ended up going this way to segment my front and back ends more completely. |
Another approach i would recommend is to use your production web server (e.g. nginx) to serve your static content. |
@hmajid2301, Thanks! imort flask
def get(filename):
response = flask.send_from_directory('static', filename)
response.direct_passthrough = False
return response In schema I use: 'static/{filename}':
get:
parameters:
- name: filename
in: path
# and so on Use openapi 3.0.0, connexion==2.0.2, Werkeug==0.14.1. |
A solid example of how to serve static content, with or without catchall, would be greatly appreciated. I've spent an hour trying to follow what's stated here without any success. I've done it before in Flask, but how to access flask "Correctly" using the proper connexion methodology doesn't work either. I realize this is an API system and not designed for static, but sometimes you need to serve one or two small static items to make life better. |
For someone come here like me using openapi 3 rather than swagger 2: Swagger.yaml:
controller file:
|
One other possibility is to use Whitenoise to serve the static files |
No description provided.
The text was updated successfully, but these errors were encountered: