This url shortener is built with FastAPI and asyncpg driver for Postgres, so you can expect it to be pretty responsive (3-6 ms).
- CD into project root and install python packages with
pipenv install
or you with preffered package manager. - Spin up new local postgres database. This setup uses Postgres asyncpg driver.
- Create
.env
file with the following contents and modify your postgres credentials/db name.
DATABASE_URL=postgresql+asyncpg://postgres:root@localhost/dbname
APPLICATION_SECRET=123456
CURRENT_HOST=http://127.0.0.1:8000
PRIVATE_MODE=False
ENV_NAME=development
- Run
uvicorn app:app --reload
- Inspect API documentation served with Swagger http://127.0.0.1:8000/docs
If your don't want to go public, then set PRIVATE_MODE=True
and adjust your client request headers to include Authorization token.
Sample:
"Authorization": "Bearer {APPLICATION_SECRET}"