Is it possible to run micropython scripts loaded from hTTP?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
andrews
Posts: 2
Joined: Thu Mar 21, 2019 9:03 pm

Is it possible to run micropython scripts loaded from hTTP?

Post by andrews » Thu Mar 21, 2019 9:06 pm

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?

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

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

Post by jickster » Thu Mar 21, 2019 10:42 pm

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"?

oclyke
Posts: 11
Joined: Tue Mar 19, 2019 4:55 am

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

Post by oclyke » Fri Mar 22, 2019 3:40 am

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.

andrews
Posts: 2
Joined: Thu Mar 21, 2019 9:03 pm

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

Post by andrews » Sat Mar 23, 2019 9:15 pm

@jickster yes I mean load and run a .py file from http

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

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

Post by jickster » Sun Mar 24, 2019 2:04 am

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

Post Reply