-
Notifications
You must be signed in to change notification settings - Fork 121
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
Better URLs #15
Comments
This is actually the issue I talked to @rrothe about. I spend the entire day thinking about a good path to choose, especially with only some visualisers having settings. I have a branch currently that breaks it down. It kind of goes like this: It is already an improvement because it adds I like the idea of being RESTful with this. That would allow scripted access to the service as well! IMHO, the REST interface should be implemented next to the frontend you currently have, though. I see the advantage of both. I hope this isn't too much of a brain dump. Let me know if my thoughts help :) If you want to see how my branch behaves you can check it out here: https://github.com/jan-xyz/picasso/tree/make_files_reusable |
Good suggestions for sure --I'm not really a web developer, and it definitely shows in the structure of this application! RESTful URLs would really professionalize the project a bit, and make it a bit easier to write tests -- yes we'll need to update them, but I can work with you on that. I like the idea of selecting the file(s) first, but I wasn't able to get that working probably for the reason you described. If you're tackling this, there's a couple knock-on issues that are a little embarrassing that you may consider looking at. In the file upload and download I ran into the problem of browsers caching files, since they would have the exact same path. I worked around this by adding a timestamp to the filename, but I think that's really inelegant. Maybe you can suggest a better way? |
with RESTful URLs you mean having query strings? Or do you mean the whole thing being actually RESTful? In order for it to be RESTful you'd need to hit these requirements. I wrote up a small POC that works with query strings (example given by @knub; I added image UID): from flask import Flask, jsonify, request
# Initialize the Flask application
app = Flask(__name__)
@app.route('/result')
def result():
visualizer = request.args.get('visualizer')
image = request.args.get('image')
if visualizer == 'occlusion':
stride = request.args.get('stride')
if stride is None:
stride = 20
window = request.args.get('window')
if window is None:
window = 0.5
return jsonify(vis=visualizer, image=image, stride=stride, window=window)
return jsonify(vis=visualizer, image=image)
if __name__ == '__main__':
app.run(
host="0.0.0.0",
port=int("8080")
) If you GET http://localhost:8080/result?visualizer=occlusion&image=UID_of_image_here&stride=30&window=1 you can play with the parameters. The POC only supports the occlusion visualiser to have settings. For it to work this way you'd need a separate step before to PUT images and respond with the UID for that image. Regarding the images, I would suggest storing them under their hashed value (maybe md5). That way you can be sure that even if you get an image called I am no expert in web development, I usually work in networking and IT automation, but I am certainly interested to work on this and get my hands dirty 👍 |
Visualization is determined with a cookie now, but a URL would be the obviously better way.
Also per @knub
The text was updated successfully, but these errors were encountered: