Page 1 of 1

Is it possible to run micropython scripts loaded from hTTP?

Posted: Thu Mar 21, 2019 9:06 pm
by andrews
I'm thinking of a C project that embeds a micropython interpreter.

I'd like the C program to load a python script from hTTP or HTTPS and get the micropython intepreter to execute the script

How practical/hard is this?

Any downsides?

Re: Is it possible to run micropython scripts loaded from hTTP?

Posted: Thu Mar 21, 2019 10:42 pm
by jickster
andrews wrote:
Thu Mar 21, 2019 9:06 pm
to load a python script from hTTP or HTTPS
Do you mean "loads a .py file from http"?

Re: Is it possible to run micropython scripts loaded from hTTP?

Posted: Fri Mar 22, 2019 3:40 am
by oclyke
Hi andrews,

This sort of thing is certainly possible - particularly if you already know how you will retrieve the file via HTTP. There is an example of how to embed MicroPython in a C project here: https://github.com/micropython/micropyt ... /embedding

In addition to the 'mp_lexer_new_from_str_len' function there is also 'mp_lexer_new_from_file' so you should be able to start running MicroPython from a file that you store on your device.

Re: Is it possible to run micropython scripts loaded from hTTP?

Posted: Sat Mar 23, 2019 9:15 pm
by andrews
@jickster yes I mean load and run a .py file from http

Re: Is it possible to run micropython scripts loaded from hTTP?

Posted: Sun Mar 24, 2019 2:04 am
by jickster
oclyke wrote:Hi andrews,

This sort of thing is certainly possible - particularly if you already know how you will retrieve the file via HTTP. There is an example of how to embed MicroPython in a C project here: https://github.com/micropython/micropyt ... /embedding

In addition to the 'mp_lexer_new_from_str_len' function there is also 'mp_lexer_new_from_file' so you should be able to start running MicroPython from a file that you store on your device.
This answer should give you what you need.

Reply if you need more help.


Sent from my iPad using Tapatalk Pro