Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for list besides from string format of html file #41

Closed
curlyz opened this issue Aug 17, 2018 · 5 comments
Closed

add support for list besides from string format of html file #41

curlyz opened this issue Aug 17, 2018 · 5 comments

Comments

@curlyz
Copy link

curlyz commented Aug 17, 2018

For many case , html file will be loaded from flash into a string and then will be pass to WriteResponseOK.
In my application , having upto 50K of heap , but it is fragmented , a html file size of 6KB is failed to loads due to MemoryError
To overcome this , I create a list , load the html in chunk of 100bytes , modified the _write() to accept the list , it write to socket pieces by pieces.
Since micropython doesnt handle heap fragmentation , I think my experiences with this issue will help .

@jczic
Copy link
Owner

jczic commented Aug 17, 2018

You are on a very limited microcontroller right ?
The memory of ESP32 and pycom OEM modules is around of 4Mb.
If you have a large .pyhtml file, how you solve it ?

@curlyz
Copy link
Author

curlyz commented Aug 17, 2018

I am using ESP32 for this , if the file is too big , then I would suggest

def _httpResponse_GET():
  f = open('somthing.pyhtml')
  while True : 
    temp = f.read(100) 
    if len(temp) == 0: 
      break
    socket.write(temp)
  f.close()

I am not using readline because somehow , Python having problem with '\r' and '\n' , and also , I don't want to have problem with compressed file

@jczic
Copy link
Owner

jczic commented Aug 17, 2018

It's impossible with pyhtml ... (this is a templating language).

@curlyz
Copy link
Author

curlyz commented Aug 17, 2018

I see , since the filename can be passed through , the function simply check if the file is html or pyhtml
My method is just a error-prone method for large string file and I think it only work with html.

@curlyz curlyz closed this as completed Aug 17, 2018
@jczic
Copy link
Owner

jczic commented Oct 20, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants