diff --git a/README.md b/README.md index d65723a..1a75f30 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,18 @@ Shortenit is a tool to shorten urls. **NOTE**: This is a very early draft project. Contributions are welcome. +## Install + +To install `shortenit` and all of its dependencies for development, run the following script. + +``` shell +$ scripts/install.sh +``` + ## Running -To run `shortenit`, edit the configuration file found in [config/config.yaml](config/config.yaml) then run the following commands. +To run `shortenit` for development, edit the configuration file found in [config/config.yaml](config/config.yaml) then run the following script. ```text -$ pip install -e . -$ shortenit +$ scripts/run.sh ``` diff --git a/config/config.yaml b/config/config.yaml index 93bfec7..042ccfd 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -2,6 +2,7 @@ Server: host: 127.0.0.1 port: 8000 cors: False + static_folder: frontend/build Web: host: 127.0.0.1 diff --git a/docs/conf.py b/docs/conf.py index 0a415e5..aa77d65 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,29 +6,28 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'shortenit' -copyright = '2024, Elia el Lazkani' -author = 'Elia el Lazkani' -release = '0.0.0' +project = "shortenit" +copyright = "2024, Elia el Lazkani" +author = "Elia el Lazkani" +release = "0.0.0" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.viewcode', - 'sphinx_autodoc_typehints', + "sphinx.ext.autodoc", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.viewcode", + "sphinx_autodoc_typehints", ] -templates_path = ['_templates'] +templates_path = ["_templates"] exclude_patterns = [] - # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'alabaster' -html_static_path = ['_static'] +html_theme = "alabaster" +html_static_path = ["_static"] diff --git a/frontend/src/components/URLShortener/URLShortener.tsx b/frontend/src/components/URLShortener/URLShortener.tsx index a56dae2..492a964 100644 --- a/frontend/src/components/URLShortener/URLShortener.tsx +++ b/frontend/src/components/URLShortener/URLShortener.tsx @@ -32,14 +32,14 @@ export default function () { // Send the POST request to the backend await axios - .post("http://127.0.0.1:8000/shortenit", { + .post("http://127.0.0.1:8000/api/v1/shorten", { url: url, timestamp: timestamp, }) .then((response) => { if (response) { const code: string = response.data.url; - const fullShortenedUrl: string = `http://127.0.0.1:8000/${code}`; + const fullShortenedUrl: string = `http://127.0.0.1:8000/r/${code}`; setShortenedUrl(fullShortenedUrl); setShowInput(true); } diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 0000000..0ad942e --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd frontend +npm install + +cd .. +poetry install diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000..d9faa87 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd frontend +npm run build +cd .. +poetry run shortenit "$@" diff --git a/shortenit/main.py b/shortenit/main.py index b3258a1..1963860 100644 --- a/shortenit/main.py +++ b/shortenit/main.py @@ -54,8 +54,7 @@ def main() -> typing.NoReturn: def shorten_it(config: dict, session: Session, data: str, ttl: int): - shortener_config = config.get("Shortener", None) - shortener = Shortener(session, shortener_config) + shortener = Shortener(session, config) identifier = shortener.generate_uuid() if identifier: try: diff --git a/shortenit/templates/index.html b/shortenit/templates/index.html deleted file mode 100644 index 0ba5307..0000000 --- a/shortenit/templates/index.html +++ /dev/null @@ -1,121 +0,0 @@ - - - -
- - - - - - -