@roganjosh They do, but when you make them nested blueprints where it's a child of a parent the static web path will become /grandparent/parent/child/static for example. However the child static folder may be in the folder app/blueprints/grandparent/blueprints/parent/blueprints/child/static
Flask clearly knows that path as it has to map the web path to the filesystem path to serve the files. I'm trying to find out how to get that filesystem path, opposed to doing some hacky string splitting and building.
@crypticツ This is news to me. I know that you can have separate templates for blueprints but not static. I can only think that url_for might be used to join the path up to the entry point of your app, but I have no idea how flask resolves this for you sorry
@NordineLotfi I'm looking at this again this morning and I don't follow what changed for this. The fact that they passed a server here shouldn't make any difference. In my case, I do pass a server but I also register a path as a shim
Because the server now ignores the base path (I'm gonna stomp this with a PR at some point, I'm sure. It's dumb), I've used:
server = flask.Flask(__name__)
@server.route('/', methods=['GET'])
def homepage():
paths = [f"{page['name']} - {page['path']} - {page['relative_path']}" for page in page_registry.values()]
return render_template_string(f"""
<a href="https://testing-abcd.peak.ai/api/route/app_direct/default/home">Click Me</a>
{paths}
""")
I've made that button so I can at least tell that I am definitely landing on the base path page. If I can get the link working, I'll upgrade it to a straight redirect and nobody need know the abomination going on behind the scenes to make things work
If you have a function like download_file_from_http_api(url) that should return contents of a remote file in a streaming manner and also somehow let the caller know the size of the file (based the content-length header; say, to let the caller display a progress bar), what return value makes the most sense? I could think of a file-like object with the content_length attribute, a chunk iterator with the content_length attribute, and a tuple of (chunk_iterator, content_length)
Another option is to use a handy function get_file_size_from_http_api(url) and call it before download_file_from_http_api(url) (which would then need to return just the file-like object/iterator), but this seems wasteful
Hello, i am trying to make some images (print screens) using Windows pickpick app. The problem is that in the pyqt5 window i want to capture i have some widgets such as QSliders and with those widgets the auto scroll of pick pick stop at this widgets.
How can i run event.ignore of QSliders,... so to stop the mouseWheelEvent ?
Nah, thanks :) I think I've done something similar in the past
Thanks for the suggestion, I'll probably use a file-like object. download_file_from_http_api(url) will likely have to return something like AsyncFileStream or SyncFileStream depending on its type (i.e., async or plain)
Speaking of, I have a design question. If you want to turn an iterator into a file object, you need to know whether it yields strings or bytes. I've solved this by taking str/bytes as input in the constructor (like Iterable2File(['line 1'], str)), but the problem with this is that it's impossible to write a correct type annotation for it. Should I take strings as input instead?
I annotated it as Literal[str, bytes], but apparently type checkers aren't very happy about that ¯\_(ツ)_/¯
@roganjosh I'm really tempted to try to figure out which version is causing the problem and why. Can you tell me the exact version for shinyproxy and dash? (unless either of them are forked/custom version?)
if not, I guess I could just make a test case and try it on every version, but that may take some time for shinyproxy (since it needs a docker image? although I saw somewhere that it could be set up without one on linux)
Honestly though, not a big deal. What I should be more concerned with is how useful it is, particularly when you're instantiating the class and looking at your IDE suggestions. Which is... reasonable, I guess?
It's annoying how you constantly run into road blocks because you're trying to write an annotation for something that's not considered a "type". You need a function that returns a 0-length iterable? Too bad, Callable[[], Iterable] is the best you can do, because the length of the iterable isn't related to its type. But apparently Literal is a type.
Nah, contracts would be public information. Your IDE could tell you that you're passing invalid arguments to a function. Tests don't enable your IDE to do that. You don't even ship tests
@KarlKnechtel Still, it proves that typing was never the goal. The goal was always to establish a contract between the caller and the callee