GithubHelp home page GithubHelp logo

Comments (2)

RuixiangS avatar RuixiangS commented on June 2, 2024

Case: Add an additional question when I use emmett develop --interface asgi
I generate a new request whose headers["Api-key"]="not_foobar", otherwise condition will not work properly.
Expected: otherwise return {"error": "not authorized"}

Traceback (most recent call last):
  File "D:\Anaconda\envs\emmett-frame\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "D:\Anaconda\envs\emmett-frame\lib\site-packages\emmett\asgi\handlers.py", line 194, in __call__
    await asyncio.wait_for(
  File "D:\Anaconda\envs\emmett-frame\lib\asyncio\tasks.py", line 455, in wait_for
    return await fut
  File "D:\Anaconda\envs\emmett-frame\lib\site-packages\emmett\http.py", line 112, in asgi
    await self._send_body(send)
  File "D:\Anaconda\envs\emmett-frame\lib\site-packages\emmett\http.py", line 165, in _send_body
    'body': self.encoded_body,
  File "D:\Anaconda\envs\emmett-frame\lib\site-packages\emmett\http.py", line 160, in encoded_body
    return self.body.encode('utf-8')
AttributeError: 'dict' object has no attribute 'encode'

Test

import requests

url = "http://localhost:8000/todo"
headers = {"Api-Key": "not_foobar"}
response = requests.get(url, headers=headers)

if response.status_code == 200:
    tasks = response.json()["tasks"]
    print(tasks)
else:
    print("Error:", response.status_code, response.json())

from emmett.

gi0baro avatar gi0baro commented on June 2, 2024

My bad I didn't check the README example was still valid with 2.5

You can find the updated code in master

from emmett.

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.