GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
560 stars 125 forks source link

Fix curl URL for Live Updating demo #437

Closed rnestler closed 2 months ago

rnestler commented 1 year ago

The page redirects from http to https:

curl http://djangoplotlydash.com/dpd/views/poke/ -d'{"channel_name":"live_button_counter","label":"named_counts","value":{"click_colour":"red"}}'

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>
rnestler commented 1 year ago

Hmm but on the other hand this will break testing of the demo.

delsim commented 1 year ago

I think the scheme (ie http or https) needs to be derived from the request object used to render the view. It should be able to indicate what is used on the client, even allowing for a reverse proxy or similar.

GibbsConsulting commented 1 year ago

Telling curl to redirect (and as a POST) seems to work:

curl -L --post301 --post302 http://djangoplotlydash.com/dpd/views/poke/ -d'{"channel_name":"live_button_counter","label":"named_counts","value":{"click_colour":"cyan"}}'

This is possibly a bit safer than trying to work out what the scheme is (it should be forwarded on by any intervening reverse proxy, but will always be a potential point of failure).

GibbsConsulting commented 2 months ago

Closing as this PR is no longer needed