This file contains hidden or 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
export DEBUG=1 | |
export SECRET_KEY=123456 | |
export DJANGO_SETTINGS_MODULE=fastapi_django.settings |
This file contains hidden or 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
> python main.py | |
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) | |
INFO: Started reloader process [34460] using statreload | |
INFO: Started server process [34468] | |
INFO: Waiting for application startup. | |
INFO: Application startup complete. |
This file contains hidden or 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
> pip install fastapi uvicorn |
This file contains hidden or 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
> cd fastapi_django | |
> ./manage.py startapp users | |
> ./manage.py makemigrations | |
Migrations for 'users': | |
users/migrations/0001_initial.py | |
- Create model UserModel | |
> ./manage.py migrate | |
Operations to perform: | |
Apply all migrations: users | |
Running migrations: |
This file contains hidden or 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
> tree fastapi_django | |
fastapi_django | |
├── fastapi_django | |
│ ├── __init__.py | |
│ └── settings.py | |
└── manage.py |
This file contains hidden or 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
> tree fastapi_django | |
fastapi_django | |
├── fastapi_django | |
│ ├── __init__.py | |
│ ├── asgi.py | |
│ ├── settings.py | |
│ ├── urls.py | |
│ └── wsgi.py | |
└── manage.py |
This file contains hidden or 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 |
This file contains hidden or 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 os | |
DEBUG = os.environ.get('DEBUG', False) | |
SECRET_KEY = os.environ.get('SECRET_KEY', '') | |
USE_TZ = True | |
TIME_ZONE = 'America/Sao_Paulo' |
This file contains hidden or 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
> pip install Django | |
> django-admin.py startproject fastapi_django |
This file contains hidden or 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
var loadTemplate = function (path, callback, asElement) { | |
/* | |
* Carrega um template Mustache remoto. | |
*/ | |
var request = window.XMLHttpRequest ? | |
new XMLHttpRequest() : | |
new ActiveXObject('Microsoft.XMLHTTP'); | |
request.addEventListener('load', function () { | |
var templateContent = this.responseText, |
NewerOlder