How to POST html data to be handled by a route endpoint
DL Neil
PythonList at DancesWithMice.info
Sun Mar 8 15:37:26 EDT 2020
On 8/03/20 8:47 AM, Richard Damon wrote:
> On 3/7/20 5:15 AM, Νίκος Βέργος wrote:
>> When superhost.gr/test tries to post html form data to the route endpoint '/mailform' it sends it to superhost.gr/mailform and NOT at superhost.gr/test/mailform as it should have done.
>>
> The HTML path /mailform means server relative path, so the path is
> relative to the SERVER, not the current page, so it would be
> superhost.gr/mailform
>
> The other format goes through a function which might re-interpret the
> path and either make it page relative or add in the path of the current
> page to get to /test/mailform
+1
May I recommend two techniques:
1 before using a URL from Python, check what happens in your favorite
web browser (with exactly the same values - not what you might
think/expect as an expansion). This helps narrow-down the problem
between the two choices (in this case) - the language or the web-server.
2 use your logging system for testing/debugging, ie build-in logging
'early' rather than retro-fitting it to a newly-working system (as seems
to be the habit amongst some of my colleagues). Thus, a glance at the
log would tell you the *exact* URL that Python has attempted to use -
and likely, much more besides...
(remember that the logging library has 'levels' of logging, eg DEBUG,
built-in and available to you 'for free'; so encoding it 'earlier'
rather than 'later' also gives you debug-print-style intelligence for-free!)
Remember also, to configure the web server to provide similarly...
--
Regards =dn
More information about the Python-list
mailing list