Re: Python and Cors

Donal McMullan <[email protected]> Sun, 27 Aug 2017 18:03:03 +0100
Newsgroups gmane.comp.python.twisted.web
Message-ID <CADf-aJFbt40k9oAEonW-wL1rHg=EFQcwguGo-Z7sBWRHZfq4bw@mail.gmail.com>
--===============2372508534346305668==
Content-Type: multipart/alternative; boundary="94eb2c194e9cc812a30557bf2684"

--94eb2c194e9cc812a30557bf2684
Content-Type: text/plain; charset="UTF-8"

Perhaps you just need to set the 'Access-Control-Allow-Origin' header?
Something like this might work:


# Import necessary files

import serial

from twisted.web.resource import Resource

# Setup Arduino at correct speed

try:

    arduino = serial.Serial('/dev/ttyACM0', 9600)

except:

    arduino = serial.Serial('/dev/ttyACM1', 9600)



class MoveServo(Resource):

    isLeaf = True

    permitted_origins = ('http://192.168.1.122:9000',)



    def render_GET(self,request):

        if origin in (self.permitted_origins):

            request.setHeader('Access-Control-Allow-Origin', origin)

        try:

            # Send value over serial to the Arduino

            arduino.write(request.args['value'][0])

            return 'Success'

        except:

            return 'Failure'



resource = MoveServo()

On 27 August 2017 at 17:10, Deve Krehbiel <[email protected]> wrote:

> First post so forgive me if I am not explaining this right.
>
> I am trying to make a baby cam and then heavily document it for everyone
> to have access to. I am using a Raspberry Pi with Rasbian. I am using
> mjpg-streamer for the streaming with no problems.
>
> The problem is I am also using two servos for pan and tilt. To accomplish
> this I am using an Arduino Uno. This is so I can add IR lighting for night
> vision, etc later. I am not a programmer so this is getting frustrating
> after a few weeks of failure.
>
> How is it failing you might ask..well, its working perfectly with only ONE
> exception:
> Every time I push the button for left/right/up/down I get this:
>
> XMLHttpRequest cannot load http://192.168.1.122:81/servos.rpy?value=100P.
> No 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://192.168.1.122:9000' is therefore not allowed
> access.
>
> On the local area network, it still works, but taking it to the internet
> it does not.
>
> Here are the two programs that make this happen. One is servos.rpy and the
> other is the supporting HTML/Get script;
> ****
> servos.rpy
> -----------------------------------
> # Import necessary files
> import serial
> from twisted.web.resource import Resource
> # Setup Arduino at correct speed
> try:
>         arduino = serial.Serial('/dev/ttyACM0', 9600)
> except:
>         arduino = serial.Serial('/dev/ttyACM1', 9600)
>
> class MoveServo(Resource):
>         isLeaf = True
>         def render_GET(self,request):
>                 try:
>                 # Send value over serial to the Arduino
>                         arduino.write(request.args['value'][0])
>                         return 'Success'
>                 except:
>                         return 'Failure'
>
> resource = MoveServo()
> ***
>
> Now for the HTML/Get script:
>
> **
> <!doctype html>
> <html>
> <head>
> <title>Make Use Of DIY Security Camera</title>
> <style type="text/css">
> #container {
> /* center the content */
> margin: 0 auto;
> text-align: center;
> }
> </style>
> </head>
> <body>
> <div id="container">
> <img src="/?action=stream" /><br>
> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/
> jquery.min.js"></script><br />
> <button onclick="servos.move('P', 10)">Left</button>
> <button onclick="servos.move('P', -10)">Right</button>
> <button onclick="servos.move('T', -10)">Down</button>
> <button onclick="servos.move('T', 10)">Up</button>
> </div>
> </body>
> <script>
> var servos;
> $( document ).ready(function() {
> servos = moveServos();
> });
> function moveServos() {
> // Store some settings, adjust to suit
> var panPos = 70,
> tiltPos = 90,
> tiltMax = 170,
> tiltMin = 45,
> panMax = 170,
> panMin = 20;
> return {
> move:function(servo, adjustment) {
> var value;
> if(servo == 'P') {
> if(!((panPos >= panMax && adjustment > 0) || (panPos <= panMin &&
> adjustment < 0))) {
> // Still within allowed range, "schedule" the movement
> panPos += adjustment;
> }
> value = panPos + 'P';
> }
> else if(servo == 'T') {
> if(!((tiltPos >= tiltMax && adjustment > 0) || (tiltPos <= tiltMin &&
> adjustment < 0))) {
> // Still within allowed range, "schedule" the movement
> tiltPos += adjustment;
> }
> value = tiltPos + 'T';
> }
> // Use AJAX to actually move the servo
> $.get('http://192.168.1.122:81/servos.rpy?value=' + value);
> },
> }
> }
> </script>
> </html>
>
> *****
> Twisted is started:  sudo twistd -n web -p 81 --path /usr/local/www/
>
> I would be forever grateful if someone could take a serious look at this
> and tell me where I am going wrong. Once this is fixed, I can start
> documenting the entire system for everyone. Thank you!
>
> Deve
>
> _______________________________________________
> Twisted-web mailing list
> [email protected]
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>

--94eb2c194e9cc812a30557bf2684
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Perhaps you just need to set the &#39;Access-Control-=
Allow-Origin&#39; header? Something like this might work:</div><div><br></d=
iv><div><br></div><div># Import necessary files =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0</div><div>import serial =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div><div>fro=
m twisted.web.resource import Resource =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div><div># Setup Arduino at correct speed =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2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=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 def render=
_GET(self,request): =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 if origin in (self.permitted_origins): =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 request.setH=
eader(&#39;Access-Control-Allow-Origin&#39;, origin) =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 try: =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Send value ove=
r serial to the Arduino =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A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=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=C2=A0</div><div>resource =3D MoveServo()=C2=A0</div></div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On 27 August 2017 at 17:10,=
 Deve Krehbiel <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]"=
 target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr">First post so forgive me if I am not e=
xplaining this right.=C2=A0<div><br></div><div>I am trying to make a baby c=
am and then heavily document it for everyone to have access to. I am using =
a Raspberry Pi with Rasbian. I am using mjpg-streamer for the streaming wit=
h no problems.=C2=A0</div><div><br></div><div>The problem is I am also usin=
g two servos for pan and tilt. To accomplish this I am using an Arduino Uno=
. This is so I can add IR lighting for night vision, etc later. I am not a =
programmer so this is getting frustrating after a few weeks of failure.</di=
v><div><br></div><div>How is it failing you might ask..well, its working pe=
rfectly with only ONE exception:</div><div>Every time I push the button for=
 left/right/up/down I get this:</div><div><br></div><div>XMLHttpRequest can=
not load <a href=3D"http://192.168.1.122:81/servos.rpy?value=3D100P" target=
=3D"_blank">http://192.168.1.122:81/<wbr>servos.rpy?value=3D100P</a>. No &#=
39;Access-Control-Allow-Origin&#39; header is present on the requested reso=
urce. Origin &#39;<a href=3D"http://192.168.1.122:9000" target=3D"_blank">h=
ttp://192.168.1.122:9000</a>&#39; is therefore not allowed access.</div><di=
v><br></div><div>On the local area network, it still works, but taking it t=
o the internet it does not.</div><div><br></div><div>Here are the two progr=
ams that make this happen. One is servos.rpy and the other is the supportin=
g HTML/Get script;</div><div>****</div><div>servos.rpy</div><div>----------=
--------------------<wbr>-----</div><div><div># Import necessary files</div=
><div>import serial</div><div>from twisted.web.resource import Resource</di=
v><div># Setup Arduino at correct speed</div><div>try:</div><div>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 arduino =3D serial.Serial(&#39;/dev/ttyACM0&#39;, 9600)</=
div><div>except:</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 arduino =3D serial.S=
erial(&#39;/dev/ttyACM1&#39;, 9600)</div><div><br></div><div>class MoveServ=
o(Resource):</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 isLeaf =3D True</div><di=
v>=C2=A0 =C2=A0 =C2=A0 =C2=A0 def render_GET(self,request):</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 try:</div><div>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <span style=3D"white-space=
:pre-wrap">		</span># Send value over serial to the Arduino</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 arduino.write(request.args[&#39;<wbr>value&#39;][0])</div><div>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 return &#39;Success&#39;</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 except:</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return &#39;Failure&#3=
9;</div><div><br></div><div>resource =3D MoveServo()</div></div><div>***</d=
iv><div><br></div><div>Now for the HTML/Get script:</div><div><br></div><di=
v>**</div><div><div>&lt;!doctype html&gt;</div><div>&lt;html&gt;</div><div>=
<span style=3D"white-space:pre-wrap">	</span>&lt;head&gt;</div><div><span s=
tyle=3D"white-space:pre-wrap">		</span>&lt;title&gt;Make Use Of DIY Securit=
y Camera&lt;/title&gt;</div><div><span style=3D"white-space:pre-wrap">		</s=
pan>&lt;style type=3D&quot;text/css&quot;&gt;</div><div><span style=3D"whit=
e-space:pre-wrap">			</span>#container {</div><div><span style=3D"white-spa=
ce:pre-wrap">				</span>/* center the content */</div><div><span style=3D"w=
hite-space:pre-wrap">				</span>margin: 0 auto;<span style=3D"white-space:p=
re-wrap">	</span></div><div><span style=3D"white-space:pre-wrap">				</span=
>text-align: center;</div><div><span style=3D"white-space:pre-wrap">			</sp=
an>}</div><div><span style=3D"white-space:pre-wrap">		</span>&lt;/style&gt;=
</div><div><span style=3D"white-space:pre-wrap">	</span>&lt;/head&gt;</div>=
<div><span style=3D"white-space:pre-wrap">	</span>&lt;body&gt;</div><div><s=
pan style=3D"white-space:pre-wrap">		</span>&lt;div id=3D&quot;container&qu=
ot;&gt;</div><div><span style=3D"white-space:pre-wrap">			</span>&lt;img sr=
c=3D&quot;/?action=3Dstream&quot; /&gt;&lt;br&gt;</div><div><span style=3D"=
white-space:pre-wrap">			</span>&lt;script src=3D&quot;<a href=3D"https://a=
jax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js" target=3D"_blank">=
https://ajax.googleapis.<wbr>com/ajax/libs/jquery/3.1.0/<wbr>jquery.min.js<=
/a>&quot;&gt;&lt;/script&gt;&lt;br /&gt;</div><div><span style=3D"white-spa=
ce:pre-wrap">			</span>&lt;button onclick=3D&quot;servos.move(&#39;P&#39;, =
10)&quot;&gt;Left&lt;/button&gt;</div><div><span style=3D"white-space:pre-w=
rap">			</span>&lt;button onclick=3D&quot;servos.move(&#39;P&#39;, -10)&quo=
t;&gt;Right&lt;/button&gt;</div><div><span style=3D"white-space:pre-wrap">	=
		</span>&lt;button onclick=3D&quot;servos.move(&#39;T&#39;, -10)&quot;&gt;=
Down&lt;/button&gt;</div><div><span style=3D"white-space:pre-wrap">			</spa=
n>&lt;button onclick=3D&quot;servos.move(&#39;T&#39;, 10)&quot;&gt;Up&lt;/b=
utton&gt;</div><div><span style=3D"white-space:pre-wrap">		</span>&lt;/div&=
gt;</div><div><span style=3D"white-space:pre-wrap">	</span>&lt;/body&gt;</d=
iv><div><span style=3D"white-space:pre-wrap">	</span>&lt;script&gt;</div><d=
iv><span style=3D"white-space:pre-wrap">		</span>var servos;</div><div><spa=
n style=3D"white-space:pre-wrap">		</span>$( document ).ready(function() {<=
/div><div><span style=3D"white-space:pre-wrap">			</span>servos =3D moveSer=
vos();</div><div><span style=3D"white-space:pre-wrap">		</span>});</div><di=
v><span style=3D"white-space:pre-wrap">		</span>function moveServos() {</di=
v><div><span style=3D"white-space:pre-wrap">			</span>// Store some setting=
s, adjust to suit</div><div><span style=3D"white-space:pre-wrap">			</span>=
var panPos =3D 70,=C2=A0</div><div><span style=3D"white-space:pre-wrap">			=
	</span>tiltPos =3D 90,=C2=A0</div><div><span style=3D"white-space:pre-wrap=
">				</span>tiltMax =3D 170,=C2=A0</div><div><span style=3D"white-space:pr=
e-wrap">				</span>tiltMin =3D 45,=C2=A0</div><div><span style=3D"white-spa=
ce:pre-wrap">				</span>panMax =3D 170,=C2=A0</div><div><span style=3D"whit=
e-space:pre-wrap">				</span>panMin =3D 20;</div><div><span style=3D"white-=
space:pre-wrap">			</span>return {</div><div><span style=3D"white-space:pre=
-wrap">				</span>move:function(servo, adjustment) {</div><div><span style=
=3D"white-space:pre-wrap">					</span>var value;</div><div><span style=3D"w=
hite-space:pre-wrap">					</span>if(servo =3D=3D &#39;P&#39;) {</div><div><=
span style=3D"white-space:pre-wrap">						</span>if(!((panPos &gt;=3D panMa=
x &amp;&amp; adjustment &gt; 0) || (panPos &lt;=3D panMin &amp;&amp; adjust=
ment &lt; 0))) {</div><div><span style=3D"white-space:pre-wrap">							</sp=
an>// Still within allowed range, &quot;schedule&quot; the movement</div><d=
iv><span style=3D"white-space:pre-wrap">							</span>panPos +=3D adjustmen=
t;</div><div><span style=3D"white-space:pre-wrap">						</span>}</div><div>=
<span style=3D"white-space:pre-wrap">						</span>value =3D panPos + &#39;P=
&#39;;</div><div><span style=3D"white-space:pre-wrap">					</span>}</div><d=
iv><span style=3D"white-space:pre-wrap">					</span>else if(servo =3D=3D &#=
39;T&#39;) {</div><div><span style=3D"white-space:pre-wrap">						</span>if=
(!((tiltPos &gt;=3D tiltMax &amp;&amp; adjustment &gt; 0) || (tiltPos &lt;=
=3D tiltMin &amp;&amp; adjustment &lt; 0))) {</div><div><span style=3D"whit=
e-space:pre-wrap">							</span>// Still within allowed range, &quot;schedu=
le&quot; the movement</div><div><span style=3D"white-space:pre-wrap">						=
	</span>tiltPos +=3D adjustment;</div><div><span style=3D"white-space:pre-w=
rap">						</span>}</div><div><span style=3D"white-space:pre-wrap">						</=
span>value =3D tiltPos + &#39;T&#39;;</div><div><span style=3D"white-space:=
pre-wrap">					</span>}</div><div><span style=3D"white-space:pre-wrap">				=
	</span>// Use AJAX to actually move the servo</div><div><span style=3D"whi=
te-space:pre-wrap">					</span>$.get(&#39;<a href=3D"http://192.168.1.122:8=
1/servos.rpy?value=3D" target=3D"_blank">http://192.168.1.122:<wbr>81/servo=
s.rpy?value=3D</a>&#39; + value);</div><div><span style=3D"white-space:pre-=
wrap">				</span>},</div><div><span style=3D"white-space:pre-wrap">			</spa=
n>}</div><div><span style=3D"white-space:pre-wrap">		</span>}</div><div><sp=
an style=3D"white-space:pre-wrap">	</span>&lt;/script&gt;</div><div>&lt;/ht=
ml&gt;</div></div><div><br></div><div>*****</div><div>Twisted is started: =
=C2=A0sudo twistd -n web -p 81 --path /usr/local/www/</div><div><br></div><=
div>I would be forever grateful if someone could take a serious look at thi=
s and tell me where I am going wrong. Once this is fixed, I can start docum=
enting the entire system for everyone. Thank you!</div><span class=3D"HOEnZ=
b"><font color=3D"#888888"><div><br clear=3D"all"><div><div class=3D"m_-248=
7397493353888386gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><di=
v>Deve</div></div></div></div></div></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
Twisted-web mailing list<br>
<a href=3D"mailto:[email protected]">Twisted-web@twistedmatrix.=
com</a><br>
<a href=3D"https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" =
rel=3D"noreferrer" target=3D"_blank">https://twistedmatrix.com/cgi-<wbr>bin=
/mailman/listinfo/twisted-<wbr>web</a><br>
<br></blockquote></div><br></div>

--94eb2c194e9cc812a30557bf2684--

--===============2372508534346305668==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp
c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg==

--===============2372508534346305668==--