mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-02-02 13:49:40 +01:00
Add config file
This commit is contained in:
parent
664266bafd
commit
dc4f1f21d3
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,7 +5,7 @@
|
|||||||
.vscode
|
.vscode
|
||||||
|
|
||||||
# data
|
# data
|
||||||
instance/partitioncloud.sqlite
|
instance
|
||||||
partitioncloud/partitions
|
partitioncloud/partitions
|
||||||
partitioncloud/search-partitions
|
partitioncloud/search-partitions
|
||||||
partitioncloud/static/thumbnails
|
partitioncloud/static/thumbnails
|
||||||
|
9
default_config.py
Normal file
9
default_config.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Should be copied to ../instance folder to override some values
|
||||||
|
# WARNING: Be sure not to leave spaces around `=` because this
|
||||||
|
# Config file will be used both by Python and Bash
|
||||||
|
|
||||||
|
# Generate with `python -c 'import secrets; print(secrets.token_hex())'`
|
||||||
|
SECRET_KEY="dev"
|
||||||
|
|
||||||
|
# Port to run on
|
||||||
|
PORT="5000"
|
11
make.sh
11
make.sh
@ -16,7 +16,13 @@ init () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
flask run
|
flask run --port=$PORT
|
||||||
|
}
|
||||||
|
|
||||||
|
production () {
|
||||||
|
FLASK_APP=partitioncloud /usr/bin/gunicorn \
|
||||||
|
wsgi:app \
|
||||||
|
--bind 0.0.0.0:$PORT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -27,6 +33,9 @@ usage () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [[ $1 && $(type "$1") = *"is a"*"function"* || $(type "$1") == *"est une fonction"* ]]; then
|
if [[ $1 && $(type "$1") = *"is a"*"function"* || $(type "$1") == *"est une fonction"* ]]; then
|
||||||
|
# Import config
|
||||||
|
source "default_config.py"
|
||||||
|
[[ ! -x instance/config.py ]] && source "instance/config.py"
|
||||||
$1 ${*:2} # Call the function
|
$1 ${*:2} # Call the function
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
|
@ -14,11 +14,13 @@ from .db import get_db
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
app.config.from_mapping(
|
app.config.from_mapping(
|
||||||
# a default secret that should be overridden by instance config
|
|
||||||
SECRET_KEY="dev",
|
|
||||||
# store the database in the instance folder
|
|
||||||
DATABASE=os.path.join(app.instance_path, f"{__name__}.sqlite"),
|
DATABASE=os.path.join(app.instance_path, f"{__name__}.sqlite"),
|
||||||
)
|
)
|
||||||
|
app.config.from_object('default_config')
|
||||||
|
if os.path.exists("instance/config.py"):
|
||||||
|
app.config.from_object('instance.config')
|
||||||
|
else:
|
||||||
|
print("[WARNING] Using default config")
|
||||||
|
|
||||||
app.register_blueprint(auth.bp)
|
app.register_blueprint(auth.bp)
|
||||||
app.register_blueprint(albums.bp)
|
app.register_blueprint(albums.bp)
|
||||||
|
Loading…
Reference in New Issue
Block a user