diff --git a/README.md b/README.md index fe6799b..6cbff57 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,16 @@ We are working on system, that will help tourists in cities to get information a - work in progress (but probabbly we will use rpi with external antena for wifi) # Software -- python 3.9 based server with basic web interface +- python 3.9.2 compatible server with basic web interface - python 3.x based mobile app with help of android studio -# Known issues -- no code writen (needs to be fixed app does not work because of it) +# Server +To run server you need to install +- hypercorn - "pip install hypercorn" +- fastapi - "pip install fastapi" +- requests - "pip install requests" + +then run by command - "hypercorn main:app --bind " +To connect to another rpi you need to edit settings.json with different ID and fill heartbeat table. + +This is not finished product diff --git a/app/WikiSpot/.idea/vcs.xml b/app/WikiSpot/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/app/WikiSpot/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/engine.py b/server/engine.py similarity index 100% rename from engine.py rename to server/engine.py diff --git a/files/test.jpg b/server/files/test.jpg similarity index 100% rename from files/test.jpg rename to server/files/test.jpg diff --git a/files/test.txt b/server/files/test.txt similarity index 100% rename from files/test.txt rename to server/files/test.txt diff --git a/files/test2.txt b/server/files/test2.txt similarity index 100% rename from files/test2.txt rename to server/files/test2.txt diff --git a/filesystem.json b/server/filesystem.json similarity index 99% rename from filesystem.json rename to server/filesystem.json index bfb59b2..2031326 100644 --- a/filesystem.json +++ b/server/filesystem.json @@ -19,4 +19,4 @@ "description": "toto je txt test file" } ] -} \ No newline at end of file +} diff --git a/log.txt b/server/log.txt similarity index 100% rename from log.txt rename to server/log.txt diff --git a/main.py b/server/main.py similarity index 100% rename from main.py rename to server/main.py diff --git a/settings.json b/server/settings.json similarity index 100% rename from settings.json rename to server/settings.json diff --git a/server/setup.py b/server/setup.py new file mode 100644 index 0000000..88d6fa2 --- /dev/null +++ b/server/setup.py @@ -0,0 +1,12 @@ +import tkinter +import json +height = 750 +width = 1200 +with open("settings.json", "r") as file: + settings = json.load(file) +with open("settings.json", "r") as file: + filesystem = json.load(file) +canvas = tkinter.Canvas(height=height, width=width) +canvas.pack() + +canvas.mainloop() \ No newline at end of file diff --git a/server/test.json b/server/test.json new file mode 100644 index 0000000..ea7f657 --- /dev/null +++ b/server/test.json @@ -0,0 +1,47 @@ +{ + "connected_id": 1, + "1": { + "ID": 1, + "location": "GPS", + "descrpition": { + "title": "nazov rpi ako nazov", + "description_s": "krátky popis, ktorý bude zobrazený iba v náhladovom okne", + "description_l": "dlhší popis zariadenia, ktorý bude zobrazený po otvorení", + "photo_s": "mala_fotka.png", + "photo_b": "velka_fotka.png" + }, + "files": [ + { + "name": "prehliadky", + "format": ".pdf", + "description": "tento súbor obsahuje prehliadky" + }, { + "name": "prehliadky", + "format": ".pdf", + "description": "tento súbor obsahuje prehliadky" + } + ] + }, + "2": { + "ID": 2, + "location": "GPS", + "descrpition": { + "title": "nazov rpi ako nazov", + "description_s": "krátky popis, ktorý bude zobrazený iba v náhladovom okne", + "description_l": "dlhší popis zariadenia, ktorý bude zobrazený po otvorení", + "photo_s": "mala_fotka.png", + "photo_b": "velka fotka.png" + }, + "files": [ + { + "name": "prehliadky", + "format": ".pdf", + "description": "tento súbor obsahuje prehliadky" + }, { + "name": "prehliadky", + "format": ".pdf", + "description": "tento súbor obsahuje prehliadky" + } + ] + } +} \ No newline at end of file diff --git a/server/test.py b/server/test.py new file mode 100644 index 0000000..81785ff --- /dev/null +++ b/server/test.py @@ -0,0 +1,60 @@ +import curses + +menu = ['Home', 'Play', 'Scoreboard', 'Exit'] + + +def print_menu(stdscr, selected_row_idx): + stdscr.clear() + h, w = stdscr.getmaxyx() + for idx, row in enumerate(menu): + x = w//2 - len(row)//2 + y = h//2 - len(menu)//2 + idx + if idx == selected_row_idx: + stdscr.attron(curses.color_pair(1)) + stdscr.addstr(y, x, row) + stdscr.attroff(curses.color_pair(1)) + else: + stdscr.addstr(y, x, row) + stdscr.refresh() + + +def print_center(stdscr, text): + stdscr.clear() + h, w = stdscr.getmaxyx() + x = w//2 - len(text)//2 + y = h//2 + stdscr.addstr(y, x, text) + stdscr.refresh() + + +def main(stdscr): + # turn off cursor blinking + curses.curs_set(0) + + # color scheme for selected row + curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE) + + # specify the current selected row + current_row = 0 + + # print the menu + print_menu(stdscr, current_row) + + while 1: + key = stdscr.getch() + + if key == curses.KEY_UP and current_row > 0: + current_row -= 1 + elif key == curses.KEY_DOWN and current_row < len(menu)-1: + current_row += 1 + elif key == curses.KEY_ENTER or key in [10, 13]: + print_center(stdscr, "You selected '{}'".format(menu[current_row])) + stdscr.getch() + # if user selected last row, exit the program + if current_row == len(menu)-1: + break + + print_menu(stdscr, current_row) + + +curses.wrapper(main) \ No newline at end of file diff --git a/version.json b/server/version.json similarity index 100% rename from version.json rename to server/version.json