Skip to content
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

Serve static files in web.app.route? #93

Closed
judoole opened this issue Aug 26, 2013 · 4 comments
Closed

Serve static files in web.app.route? #93

judoole opened this issue Aug 26, 2013 · 4 comments

Comments

@judoole
Copy link

judoole commented Aug 26, 2013

Is that possible as of now? Tried reading up on Flask and create a folder named static. But that did not seem to work.

@heyman
Copy link
Member

heyman commented Aug 26, 2013

Hi! I'm not sure what you are trying to do. What static files do you want to serve? Something for the locust web UI?

@judoole
Copy link
Author

judoole commented Aug 26, 2013

Yep. Might well not be anything that is useful for a real case scenario. Just putting together a runnable example and thought bundling togheter some simple static html files was easy to show the html-browsing capabilities. Test against it self so to speak.

@heyman
Copy link
Member

heyman commented Aug 26, 2013

Ah, I see. You should be able to do this with a Flask blueprint. Here's an example that should serve the files in the locustfile.py's directory, under /test/static if you put the code in it:

import os
from flask import Blueprint
from locust.web import app

root_path = os.path.dirname(os.path.abspath(__file__))

bp = Blueprint("test", __name__, static_folder=root, static_url_path="/static")
app.register_blueprint(bp, url_prefix="/test")

@judoole
Copy link
Author

judoole commented Aug 27, 2013

Works like charm! Thanks!

@judoole judoole closed this as completed Aug 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants