Git Product home page Git Product logo

Comments (5)

Odud avatar Odud commented on June 9, 2024

BTW I'm relatively new to asyncio but have used microdot successfully before

from microdot.

Odud avatar Odud commented on June 9, 2024

Apologies, it isn't render_template that is hanging it is the return of the template. I put some print statements around the render_template and it is working fine. I needed to make the function after the @route an async.

@app.route('/')
async def index(req):

I don't really uderstand why, but suspect this is my lack of understanding of async. Happy to close if my thought is correct

from microdot.

miguelgrinberg avatar miguelgrinberg commented on June 9, 2024

@Odud: Ah, okay, I do see what the problem is now. In MicroPython async functions are really generators. The render_template() function returns a generator as well. Microdot is confused because a non-async function is returning something that looks like what an async function would return. I need to find a way to distinguish the return value of calling an async function from a generator returned by a non-async function, which actually look the same.

In the meantime your solution is fine, just make sure any functions that use render_template() are defined as async functions. I'll investigate to see if I can figure out how to make non-async functions work as well.

from microdot.

Odud avatar Odud commented on June 9, 2024

from microdot.

Related Issues (20)

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.