Giter Club home page Giter Club logo

Comments (7)

puhitaku avatar puhitaku commented on June 14, 2024 1

FYI: throughput of large data transmission can be improved using segment kwarg. The default value is 64. The upper bound varies up to the board/SoC you use.

Example:

await send_file(request, filename, segment=256)

from micropython-nanoweb.

krishnak avatar krishnak commented on June 14, 2024

# Declare route from a dict naw.routes = { '/api/status': api_status, }

This doesn't work - it doesn't check these routes at all

from micropython-nanoweb.

hugokernel avatar hugokernel commented on June 14, 2024

Please, put a complete example.

from micropython-nanoweb.

krishnak avatar krishnak commented on June 14, 2024

Thank you for responding, I have fixed it myself. regarding the subfolder folder - the trailing / in the assets_DIR declaration was causing some issues, so I have defined it like this which has resolved many of the problems

ASSETS_DIR = 'www'
IMAGE_DIR = 'www/images'

However I had to change this %s/%s - to %s%s or else I was getting a extra / before the file name. Now everything looks resolved. Except that when I use a SVG file - the file gets downloaded but it doesn't show up. But the browser opens the SVG file if I access the html page offline. Do you have any thoughts?

 # 4. Current url have an assets extension ?
                        for extension in self.assets_extensions:
                            if request.url.endswith('.' + extension):
                                await send_file(
                                    request,
                                    **'%s%s' % (**
                                        self.STATIC_DIR,
                                        request.url,
                                    ),
                                    binary=True,
                                )

from micropython-nanoweb.

hugokernel avatar hugokernel commented on June 14, 2024

You have to handle manually the header with a correct mimetype.

from micropython-nanoweb.

krishnak avatar krishnak commented on June 14, 2024

Another issue, I have bootstrap.min.css in the same folder as my html - html as below. The browser downloads the style sheet but is not able to render it, see attached screen shot - this shows the file has downloaded in 6 seconds (which itself is too long for 195K file) but if you see it has only a size of 115KB - there seems to be some data loss hence the style sheet has not been rendered.

This is the page rendered when accessed through your webserver - which is not loading the style sheet
image

This is the page when loaded directly from the hardrive (offline) see the bootstrap stylesheet file size

image

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Home1</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" href="styles.css" />
    <link rel="stylesheet" href="bootstrap.min.css"/>
   <script" src="js/bootstrap.bundle.min.js"/>	

  </head>
  <body>
    <div class="wrapper">
      <div class="logo">
        <img
          src="images/testlogo.png"
          alt=""
        />
      </div>
      <div class="text-center mt-4 name">Switch Board Login</div>
      <form class="p-3 mt-3">
        <div class="form-field d-flex align-items-center">
          <input
            type="password"
            name="password"
            id="pwd"
            placeholder="Password"
          />
        </div>
        <button class="btn mt-3">Login</button>
      </form>
      
    </div>
  </body>
</html>

from micropython-nanoweb.

hugokernel avatar hugokernel commented on June 14, 2024

I can't guess if you don't put a code example.

And it seems to be the same problem as for SVG: A mimetype problem.

from micropython-nanoweb.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.