config file

This commit is contained in:
nyx 2025-02-01 16:25:53 -06:00
parent b94a3d2ae4
commit d65bcb3e4a
6 changed files with 42 additions and 10 deletions

2
.gitignore vendored
View file

@ -168,3 +168,5 @@ cython_debug/
instance/ instance/
images/ images/
config.json

View file

@ -28,7 +28,15 @@ and you can also run the app using [./scripts/run.sh](./scripts/run.sh) to match
the run.sh as the first run. the run.sh as the first run.
running with gunicorn (run.sh) is for production use, for master key generation (first run), please running with gunicorn (run.sh) is for production use, for master key generation (first run), please
run it in dev mode: run it in dev mode after making the config:
make the config:
```sh
cp src/imag/config.sample.json src/imag/config.json && nano config.json
```
run it:
```sh ```sh
python3 src/main.py python3 src/main.py
@ -37,7 +45,7 @@ python3 src/main.py
(make sure to save the key!) (make sure to save the key!)
and only then with gunicorn and only then with gunicorn
if you already ran it in production and don't know where the key is, run the following command : if you already ran it in production and don't know where the key is, run the following command:
```sh ```sh
rm -rf src/instance rm -rf src/instance
@ -49,9 +57,10 @@ and then run it in debug
this comes from an email the original creator got from a user: this comes from an email the original creator got from a user:
1. clone the repository : `git clone https://git.everypizza.im/n/imag` 1. clone the repository: `git clone https://git.everypizza.im/n/imag`
2. make sure you have virtualenv installed ( either through python-virtualenv / python3-virtualenv / py3-virtualenv packages, or by pip - `python3 -m pip install --user --break-system-packages --upgrade virtualenv` 2. make sure you have virtualenv installed (either through python-virtualenv / python3-virtualenv / py3-virtualenv packages, or by pip - `python3 -m pip install --user --break-system-packages --upgrade virtualenv`)
3. ensure you have sqlite3 and memcached installed : `apt install sqlite3 memcached` 3. ensure you have sqlite3 and memcached installed: `apt install sqlite3 memcached`
4. create a new virtual environment : `python3 -m virtualenv venv && source venv/bin/activate` 4. create a new virtual environment: `python3 -m virtualenv venv && source venv/bin/activate`
5. install the dependencies in the environment : `pip install -r requirements.txt` 5. install the dependencies in the environment: `pip install -r requirements.txt`
6. run the app by either running `scripts/run.sh` or by manually starting memcached and running `src/main.py` with gunicorn ( i assume you're reverse proxying it anyway ) 6. configure the instance: `cp src/imag/config.sample.json src/imag/config.json && nano config.json`
6. run the app by either running `scripts/run.sh` or by manually starting memcached and running `src/main.py` with gunicorn (i assume you're reverse proxying it anyway)

View file

@ -4,8 +4,8 @@
import secrets import secrets
import typing as t import typing as t
from os import makedirs from os import makedirs, path
import json
import flask import flask
from werkzeug.middleware.proxy_fix import ProxyFix from werkzeug.middleware.proxy_fix import ProxyFix
@ -13,6 +13,11 @@ from . import const, models
from .api import api from .api import api
from .views import views from .views import views
configLocation = path.dirname(path.abspath(__file__))
with open(configLocation + '/config.json', 'r') as f:
config = json.load(f)
message = config["message"]
__version__: str = "3.1.2-nyx" __version__: str = "3.1.2-nyx"
@ -54,6 +59,7 @@ def create_app(db: str = "sqlite:///imag.db") -> t.Tuple[flask.Flask, t.Optional
"desc_len": const.DESC_LEN, "desc_len": const.DESC_LEN,
"key_len": const.KEY_LEN, "key_len": const.KEY_LEN,
"imagv": __version__, "imagv": __version__,
"imagmessage": message
} }
@app.after_request @app.after_request

View file

@ -0,0 +1,3 @@
{
"message": "meow"
}

View file

@ -114,3 +114,7 @@ hr.thin{
width:50%; width:50%;
} }
hr.tiny {
width:25%;
}

View file

@ -60,6 +60,14 @@
<a href="https://matrix.to/#/@quotes-python:everypizza.im">@quotes-python:everypizza.im</a> <a href="https://matrix.to/#/@quotes-python:everypizza.im">@quotes-python:everypizza.im</a>
</small> </small>
</center> </center>
<hr class="tiny">
<center>
<small>
Board message: {{ imagmessage }}
</small>
</center>
<hr class="thin">
{% with messages = get_flashed_messages(with_categories=True) %} {% with messages = get_flashed_messages(with_categories=True) %}
{% if messages %} {% if messages %}