Compare commits

..

5 commits

Author SHA1 Message Date
Elia el Lazkani
a925c87872 enh(): Refactoring code 2024-12-24 01:40:50 +01:00
Elia el Lazkani
000729a925 chore(): Adds scripts to install, build and run the project 2024-12-24 01:40:15 +01:00
Elia el Lazkani
c058835f73 chore(): Initial migration into the new frontend UI 2024-12-24 01:40:15 +01:00
Elia el Lazkani
35c8dfd21a enh(): Adds configurable CORS
* Adds CORS configuration in the config file
* Enables CORS to be toggled through config
2024-12-24 00:38:37 +00:00
Elia el Lazkani
c036d042c3 fix(): Adds the pointer to the session before proceeding 2024-12-24 01:35:37 +01:00
3 changed files with 5 additions and 2 deletions

View file

@ -1,6 +1,7 @@
Server:
host: 127.0.0.1
port: 8000
cors: False
static_folder: frontend/build
Web:

View file

@ -64,9 +64,9 @@ def shorten_it(config: dict, session: Session, data: str, ttl: int):
_link = Link(data=data, pointers=[])
_pointer = Pointer(data=identifier, link_id=_link.id, link=_link, ttl=ttl)
session.add(_pointer)
_link.pointers.append(_pointer)
session.add(_link)
session.add(_pointer)
session.commit()
return _pointer.data
return None

View file

@ -25,7 +25,9 @@ class Web:
server_config = self.handler.configuration.get("Server", None)
self.app = Flask(__name__)
self.setup_routes()
CORS(self.app)
if server_config and server_config.get("cors", False):
self.logger.debug("Enabling CORS...")
CORS(self.app)
def setup_routes(self):
self.app.add_url_rule(