diff --git a/.gitignore b/.gitignore index 96138b6..862112c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ port.json +config.json *.pyc diff --git a/README.md b/README.md index 2fc4813..7f134ce 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The software is built on Python. So you will need to have python3 installed. The `python3 server.py` -It will prompt you to select a `PORT` to which on your end to bind the server. For now it binds it to your localhost. You can edit that part. We are using a standard SimpleHTTPServer python module for it. +On first run, you will be prompted to edit the newly created `config.json`. You should set the URL to be the URL in which you are hosting **Free Competitors** (ex. `http://5wxkwfl6n4abwjsqv5r6roebwbc7fnc22dq3clpooojzdmdnzzo3amad.onion/`). If you do not wish to set a URL, you should set it to `/`. Then, you should specify the port to serve on, and the CSS to use. Please tell us if you start an instance. We want to add it's link here. diff --git a/modules/render.py b/modules/render.py index bb71f4b..b56a10b 100644 --- a/modules/render.py +++ b/modules/render.py @@ -145,16 +145,19 @@ def suggestions(page, json): page = page + "" return page -def search_widget(page): +def search_widget(page, address): # Adds a search bar to the page page = page + """ -
""" + #page = page.format(ADDRESS) return page diff --git a/server.py b/server.py index ef457b6..c85b27b 100644 --- a/server.py +++ b/server.py @@ -18,11 +18,23 @@ from modules import render CSS = "https://zortazert.codeberg.page/style/styles.css" try: - with open("port.json","r") as f: - json_stuff = json.load(f) - PORT = json_stuff["port"] + if os.path.exists("config.json"): + with open("config.json","r") as f: + srvConfig = json.load(f) + ADDRESS = srvConfig["address"] + PORT = srvConfig["port"] + CSS = srvConfig["css"] except: - PORT = input("Port: ") + newConfig = open("config.json", "w") + newConfig.write("""{ + "INFO" : "You would be better off setting address to the full URL of the FreeCompetitors instance.", + "address" : "/", + "port" : "8080", + "css" : "https://zortazert.codeberg.page/style/styles.css" +}""") + newConfig.close + print("Please edit the configuration file \"config.json\".") + exit() try: PORT = int(PORT) except: @@ -73,7 +85,7 @@ class handler(BaseHTTPRequestHandler): # If the user is at the front page, let him get only the search bar page = "Please search for any software to which you would like to find a Free Software replacement.