diff --git a/.gitignore b/.gitignore index 66e5ce2..684289e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ images node_modules __pycache__ log/* +server/public/* diff --git a/client/public/index.html b/client/public/index.html index 96cbd5c..2ba5fa0 100644 --- a/client/public/index.html +++ b/client/public/index.html @@ -8,7 +8,7 @@ - + Map diff --git a/server/main.py b/server/main.py new file mode 100644 index 0000000..8d96dd4 --- /dev/null +++ b/server/main.py @@ -0,0 +1,32 @@ +import os +import asyncio +from aiohttp import web +import aiofiles + +dir = os.path.dirname(__file__) +routes = web.RouteTableDef() +app = web.Application() + +app.router.add_static("/public/", + path=os.path.join(dir, "public"), + name="public") + +@routes.get("/") +async def index(request): + async with aiofiles.open(os.path.join(dir, "public", "index.html")) as conn: + return web.Response(text=await conn.read(), content_type="text/html") + + +@routes.get("/data/{resource}") +async def data(request): + # Obrir una conexió amb base de dates + # Fer la consulta que vulgui definia pels possibles paramatres de la url + file = request.match_info["resource"] + async with aiofiles.open(os.path.join(dir, "public", "data", file)) as conn: + return web.Response(text= await conn.read(), content_type="application/json") + + +app.add_routes(routes) + +if __name__ == "__main__": + web.run_app(app) \ No newline at end of file diff --git a/server/public/index.html b/server/public/index.html new file mode 100644 index 0000000..2fa2a30 --- /dev/null +++ b/server/public/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + Map + + + +
+ + + + + + + + + + + + + + diff --git a/server/requirements.txt b/server/requirements.txt index 517acf3..ac79018 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -4,4 +4,7 @@ pypdf2 pyspellchecker numpy opencv-python -geocoder \ No newline at end of file +geocoder +aiohttp +aiofiles +fastapi \ No newline at end of file diff --git a/server/static/index.html b/server/static/index.html deleted file mode 100644 index 145d13c..0000000 --- a/server/static/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Desregistradores - - -

Desregistradores

- - \ No newline at end of file diff --git a/server/wsgi.py b/server/wsgi.py deleted file mode 100644 index 62144ad..0000000 --- a/server/wsgi.py +++ /dev/null @@ -1,20 +0,0 @@ -import os -import asyncio -import aiohttp -import aiofiles - -dir = os.path.dirname(__file__) -routes = aiohttp.RouteTableDef() -app = aiohttp.web.Application() - -app.router.add_static("/static/", - path=os.path.join(dir, "static"), - name="static") - -@routes.get("/") -async def index(): - async with aiofiles.open(os.path.join(dir, "static", "index.html")) as conn: - return web.Response(text=conn.read(), content_type="text/html") - -if __name__ == "__main__": - aiohttp.runapp(app) \ No newline at end of file