Giter Club home page Giter Club logo

Comments (9)

mikeckennedy avatar mikeckennedy commented on May 18, 2024

from modern-apis-with-fastapi.

KrunchMuffin avatar KrunchMuffin commented on May 18, 2024

At first I tried it the way you had it api = fastapi.FastAPI() then I tried like in the docs. api = FastAPI() changing the import to reflect the update. from fastapi import FastAPI

from modern-apis-with-fastapi.

mikeckennedy avatar mikeckennedy commented on May 18, 2024

Hi.

Both work. They just need to be internally consistent with the import statement:

  • import fastapi => api = fastapi.FastAPI()
  • from fastapi import FastAPI => api = FastAPI()

I personally prefer the more namespace driven approach for most code but either should work. The error looks like you might have written: import fastapi => api = fastapi.FastAPI (without ()) the first time around.

from modern-apis-with-fastapi.

KrunchMuffin avatar KrunchMuffin commented on May 18, 2024

No, haven't done that.
image

from modern-apis-with-fastapi.

mikeckennedy avatar mikeckennedy commented on May 18, 2024

Oh I see what's up. I just upgraded uvicorn to the latest version and that warning showed up. Someone screwed up the type hint in uvicorn and it thinks FastAPI won't run. But it runs fine. That's some PyCharm warning but if you run the code it still works. Not sure how to address that really other than saying just ignore it or add # noinspection PyTypeChecker on the line before.

from modern-apis-with-fastapi.

KrunchMuffin avatar KrunchMuffin commented on May 18, 2024

That's the thing, I can't get it to run.

image

from modern-apis-with-fastapi.

mikeckennedy avatar mikeckennedy commented on May 18, 2024

That is weird. Is should either crash or run but not do nothing. Exit code 0 is success. Can you add a print statement above that line to make sure it's actually running?

from modern-apis-with-fastapi.

mikeckennedy avatar mikeckennedy commented on May 18, 2024

Oh, I see your error. You have:

if __name__ == "__main":

It should be:

if __name__ == "__main__":

Next time, just type main then tab to expand out the live template and it'll write the later version.

from modern-apis-with-fastapi.

KrunchMuffin avatar KrunchMuffin commented on May 18, 2024

LOL, i was just coming to post that. THanks!

from modern-apis-with-fastapi.

Related Issues (11)

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.