Last active
April 30, 2021 17:11
-
-
Save rafaelcanovas/f891317e9214eb695ea95951b4e6f3f2 to your computer and use it in GitHub Desktop.
FastAPI + Django: app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import django # noqa | |
django.setup() # noqa | |
import uvicorn | |
from fastapi import FastAPI | |
from django.db.utils import OperationalError | |
from users.models import UserModel | |
from users.responses import UserResponse | |
app = FastAPI() | |
@app.get('/') | |
def root(): | |
users = UserModel.objects.all() | |
return UserListResponse.from_queryset(users) | |
if __name__ == '__main__': | |
uvicorn.run('main:app', debug=True, reload=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment