diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8750bee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +app/__pycache__ +venv/ \ No newline at end of file diff --git a/README.md b/README.md index a3c11cb..9fb714a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ -# url-shortener -Url-shortener project to showcase python use +# URL-shortener +URL-shortener project to showcase python use + +## Run locally +```bash +uvicorn app.main:app --reload +``` +Then check: +http://127.0.0.1:8000 \ No newline at end of file diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..d855f15 --- /dev/null +++ b/app/main.py @@ -0,0 +1,9 @@ +from fastapi import FastAPI, HTTPException +from fastapi.responses import RedirectResponse + +app = FastAPI() + +@app.get("/") +def home(): + return {"message": "URL Shortener API"} + \ No newline at end of file diff --git a/app/utils.py b/app/utils.py new file mode 100644 index 0000000..785e0b4 --- /dev/null +++ b/app/utils.py @@ -0,0 +1,7 @@ +import string +import random + +def generate_short_code(length=6): + characters = string.ascii_letters + string.digits + return ''.join(random.choice(characters) for _ in range(length)) + \ No newline at end of file