A simple URL shortener application built with FastAPI and SQLAlchemy.
$ git clone https://github.com/[YOUR_GITHUB_USERNAME]/fastapi-url-shortener.git
$ cd fastapi-url-shortener
$ poetry install
- Make a copy of the
.env.example
file and rename it to.env
- Open the newly created
.env
file in a text editor. - Replace the placeholder values in the
.env
file with your own desired values. - Save the changes to the
.env
file.
It is important to note that the values in the .env
file should not be shared publicly, as they may contain sensitive information such as secret keys.
$ poetry run uvicorn main:app --reload
You can now access the app at http://localhost:8000 (or hostname that you specified in .env
file)
The following endpoints are available:
POST /url
: Create a new shortened URL.GET /{url_key}
: Redirect to the target URL for the specified shortened URL key.GET /admin/{secret_key}
: Get information about the specified shortened URL.DELETE /admin/{secret_key}
: Delete the specified shortened URL.