generated from justuser-31/mrl_v1_license
Создание конфигурации при запуске.
This commit is contained in:
parent
3ae28ed270
commit
687912f5ba
@ -1,5 +1,3 @@
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
@ -79,7 +77,6 @@ def delete_account(api_url: str, api_token: str, username: str) -> dict:
|
||||
return {"status_code": -1, "message": f"Request failed: {str(e)}"}
|
||||
|
||||
|
||||
# print(set_quota("http://127.0.0.1:8000", "test", "test", 1000))
|
||||
# print(delete_account("http://127.0.0.1:8000", "test", "test"))
|
||||
# print(set_quota("http://proxy.del.pw:50020", "test", "test", 1000))
|
||||
# print(delete_account("http://proxy.del.pw:50020", "test", "test"))
|
||||
# print(create_account("http://proxy.del.pw:50020", "test", "test", "test", 100))
|
||||
print(create_account("http://proxy.del.pw:50020", "test", "ritmas", "ritmas", 100))
|
||||
|
||||
29
config.py
29
config.py
@ -5,9 +5,38 @@ import yaml
|
||||
CONFIG = {}
|
||||
STORAGE_ROOT = ""
|
||||
|
||||
DEFAULT_CONFIG = """# config.yaml
|
||||
server:
|
||||
host: 127.0.0.1
|
||||
port: 8000
|
||||
session_timeout: 3600 # Seconds
|
||||
video_and_image_preview: true # Use as "CDN" or not
|
||||
|
||||
security:
|
||||
api_token: "test" # Change this in production
|
||||
|
||||
storage:
|
||||
root_dir: "./file_storage" # Where store files
|
||||
default_quota_mb: 100 # Default amount of megabytes to user
|
||||
|
||||
ui:
|
||||
title: "Simple File Server"
|
||||
contact_email: "del.pw.official@gmail.com"
|
||||
disclaimer: "NO warranty or liability provided. You are SOLELY responsible for the files you upload. For deletion requests and claims use email on Telegram (prefered)"
|
||||
disclaimer_ru: "НИКАКИХ гарантий не предоставляется. Вы несете ПОЛНУЮ ответственность за загружаемые вами файлы. Для запросов на удаление и претензий используйте электронную почту или Telegram (предпочтительно)"
|
||||
register_info: 'RU: Для регистрации необходимо быть участником <a href="https://t.me/justuser31_chat_new">нашего чата</a>, а затем прописать <code>/reg_sfs</code> и следовать инструкции бота.'
|
||||
|
||||
logging:
|
||||
enabled: false
|
||||
"""
|
||||
|
||||
|
||||
def load_config():
|
||||
global CONFIG, STORAGE_ROOT
|
||||
if not os.path.isfile("config.yaml"):
|
||||
with open("config.yaml", "w") as f:
|
||||
f.write(DEFAULT_CONFIG)
|
||||
print("No config found. CREATED NEW config.yaml")
|
||||
with open("config.yaml", "r") as f:
|
||||
CONFIG = yaml.safe_load(f)
|
||||
STORAGE_ROOT = CONFIG["storage"]["root_dir"]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user