Comments (9)
from modern-apis-with-fastapi.
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.
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.
from modern-apis-with-fastapi.
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.
That's the thing, I can't get it to run.
from modern-apis-with-fastapi.
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.
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.
LOL, i was just coming to post that. THanks!
from modern-apis-with-fastapi.
Related Issues (11)
- FastAPI UI not appearing HOT 2
- Project dependencies may have API risk issues
- AWAIT ERROR HOT 1
- Runtime error when the fake data is supposed to be added HOT 11
- [Feature request] Could you please add tests? HOT 1
- Because I'm not sure what a whether app would look like... :) HOT 1
- Because UV acorns looks cool but can't serve Python code... :) HOT 2
- bootstrap not loading from layout.html HOT 2
- Course video ch.5 vid 14/14 "Concept: Async API methods" - slides vs. repo descrepancy HOT 1
- Feature request: asyncronous database queries HOT 3
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 modern-apis-with-fastapi.