Giter Club home page Giter Club logo

ampule's People

Contributors

andreasbrett avatar deckerego avatar domdfcoding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ampule's Issues

How to use with MicroPython?

I've been using Ampule with CircuitPython and love it, trying to get it to work with MicroPython and I'm stumped on the server configuration piece due to socketpool as I get ImportError: no module named 'socketpool'. Can you provide any guidance on how to configure the startup of Ampule with MicroPython?

Thanks.

Non-blocking behaviour

I was trying ampule to replace adafruit httpserver as have been seeing some issues with reliability.

I got the code working to host the html page and respond to button presses on that page - so long as running in blocking mode. However I need to run in non-blocking mode (I was polling the server instance formed with httpserver, as the hardware checks for a physical button press too).

I can't get the non-blocking examples to work - whenever I try to connect to the IP address I get:
"Error reading from socket [Errno 11] EAGAIN
Error with request: need more than 0 values to unpack"
And the device trying to connect to the IP address reports it can't connect and the connection is being reset. I see this same behaviour with my code as well when set socket.setblocking(False) too.

I've seen your advice in [(https://github.com//pull/26)] however I can't determine how to manually override the setting on the accept() socket (I assume this is what I need to do). I've tried setting the timeout on the socket created (i.e. the listening socket) that the accept socket should then inherit the timeout from, but it doesn't make any difference to the behaviour.

Any ideas why I can't get your non-blocking example to work? I'm using a pi pico running circuitpython 8.1.0.

Many thanks.

Error with request: name 'bytes_sent' is not defined

I'm trying to send an HTML file converted to a string as a response, like this:

def getHTML(filepath):
    f = open(filepath,'r', encoding="utf-8")
    html = f.read()
    f.close()
    return html

@ampule.route("/")
def light_set(request):
    return (200, {}, getHTML('cat.html'))

When I exceed about 50 lines, I get "Error with request: name 'bytes_sent' is not defined"

It looks like it's referring to this line:

while True:
      try:
          bytes_sent_total += client.send(response)
          if bytes_sent_total >= response_length:
              return bytes_sent_total
          else:
              response = response[bytes_sent:]
              continue
      except OSError as e:
          if e.errno == 11:       # EAGAIN: no bytes have been transfered
              continue
          else:
              return bytes_sent_total

I can't seem to send a file over a certain size without tripping this.

ETIMEDOUT

Error reading from socket [Errno 116] ETIMEDOUT
Error with request: need more than 0 values to unpack
Error reading from socket [Errno 116] ETIMEDOUT
Error with request: need more than 0 values to unpack

I am getting this Error after running the example webserver code for a while what does this mean?

Sending files as an HTTP response

Rather than just sending a string response to an http request I would like to send a file from an ESP32S2 board that I am running CircuitPython and ampule on. If it is possible to do this, can you tell me how? Thanks.

ERR_CONTENT_LENGTH_MISMATCH on long response strings

When serving responses longer than 2572 chars, a ERR_CONTENT_LENGTH_MISMATCH is caught by the browser:

@ampule.route("/")
def light_set(request):
    headersCss = {
        "Content-Type": "text/css; charset=UTF-8",
        "Access-Control-Allow-Origin": '*',
        "Access-Control-Allow-Methods": 'GET, POST',
        "Access-Control-Allow-Headers": 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token'
    }
    content = readFile("test.txt")
    return (200, headersCss, content)

By sending an empty header instead this increases from 2572 to 2776 chars:

@ampule.route("/")
def light_set(request):
    content = readFile("test.txt")
    return (200, {}, content)

Here's a test endpoint evaluating this behaviour. While requesting /test/2776 works and returns a string of 2776 "x", /test/2777 will result in a ERR_CONTENT_LENGTH_MISMATCH .

@ampule.route("/test/<length>")
def light_set(request, length):
    output = "X" + "x"*(int(length)-2) + "X"
    return (200, {}, output)

Adafruit AirLift

Is the library compatible with Adafruit AirLift WiFi coprocessor like the Metro M4 Express AirLift?

Ampule download file from webserver example

I embedded a link into the HTML page from example to download a file from the circuit python webserver but after downloading it there was a ERROR NO FILE from chrome how do I fix this ?

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.