Comments (7)
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.
# 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.
Please, put a complete example.
from micropython-nanoweb.
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.
You have to handle manually the header with a correct mimetype.
from micropython-nanoweb.
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
This is the page when loaded directly from the hardrive (offline) see the bootstrap stylesheet file size
<!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.
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)
- GET and POST methods? HOT 3
- Unable to get the examples working HOT 1
- Energy efficiency HOT 2
- Expending the request handler (Feature request) HOT 2
- OSError: [Errno 5] EIO Task exception wasn't retrieved HOT 2
- Slight syntax difference breaks example.py on the Pico W HOT 3
- support sending gzipped files? HOT 5
- Another issue, style sheet doesn't load fully through your server HOT 1
- POST method implementation issues HOT 1
- Memory allocation error HOT 5
- Thanks! HOT 1
- Connection Reset error when responding to request after reading part of request HOT 1
- example.py missing base64_decode() reference HOT 1
- send_response() not implemented in example.py HOT 2
- Add configurable static file folder HOT 5
- Possible updates for send_file() function HOT 2
- How to upload ? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micropython-nanoweb.