In a Flask app, or even better just using wikipedia APIs, how can I get the pageid from a Wikipedia url?
I mean from this http://en.wikipedia.org/wiki/Stack_Overflow to this http://en.wikipedia.org/wiki?curid=21721040
From the API sandbox I can work it out but only as a search from a title, not from a singular URL.
Said search example: https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&prop=pageprops&format=json&ppprop=wikibase_item&titles=Stack%20Overflow
Can I query for it in a more straightforward way and without resorting to a wikipedia search? I mean I already know the human readable url...
No, you cannot use URLs in the API, you need to use either page names or page ids to identify articles.
Notice that the https://en.wikipedia.org/w/api.php?action=query&titles=Stack%20Overflow you found is not a "search", it's just exactly the query to get you the page id from the title. Use it.