Timed exercise for building a small app with AI assistance allowed.
- You may use AI tools freely (Cursor, ChatGPT, Copilot, etc.).
- You must be able to explain every line you keep.
- Prefer a small working slice over unfinished extras.
- Time box: ~60 minutes for a working happy path.
Build a URL shortener API with Django and Django REST Framework.
POST /api/shorten/— accept a long URL, return a short code / short URLGET /<code>/— redirect to the original URL- Persist links across process restart (SQLite is already configured)
- Reject non-
http/ non-httpsURLs (includingjavascript:, empty, nonsense)
- Basic test(s) for create + redirect + invalid URL
- Unknown short code returns 404
- Simple click counter or expiry
- Auth, custom domains, analytics dashboards, Redis, Docker, deployment
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserverconfig/ # Django project settings / urls
shortener/ # Your app — implement models, serializers, views, urls
Stub endpoints are wired but intentionally unfinished. Fill them in.
# create
curl -s -X POST http://127.0.0.1:8000/api/shorten/ \
-H 'Content-Type: application/json' \
-d '{"url":"https://example.com"}'
# visit the returned short URL in a browser (or curl -i) and confirm redirect
# reject bad schemes
curl -s -X POST http://127.0.0.1:8000/api/shorten/ \
-H 'Content-Type: application/json' \
-d '{"url":"javascript:alert(1)"}'
# restart the server, then confirm the short link still works- Runnable app
- Short note in this README (or a
NOTES.md) with:- how to run
- how you tested
- one known limitation