WIP
This commit is contained in:
parent
637b00261a
commit
3c4a25e5ad
17 changed files with 197 additions and 272 deletions
|
|
@ -1,3 +1,48 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import profig
|
||||
|
||||
# constants
|
||||
FLASK_APP = "flask.app"
|
||||
|
||||
DB_URL = "main.db_url"
|
||||
|
||||
HTTP_HOST = "http.host"
|
||||
HTTP_PORT = "http.port"
|
||||
|
||||
SECURITY_SALT = "security.salt"
|
||||
SECURITY_SECRET = "security.secret"
|
||||
|
||||
MAIL_POLLING = "polling.newmail"
|
||||
COMMENT_POLLING = "polling.newcomment"
|
||||
|
||||
# variable
|
||||
params = dict()
|
||||
|
||||
|
||||
def initialize(config_pathname, flask_app):
|
||||
cfg = profig.Config(config_pathname)
|
||||
cfg.sync()
|
||||
params.update(cfg)
|
||||
params.update({FLASK_APP: flask_app})
|
||||
|
||||
|
||||
def get(key):
|
||||
return params[key]
|
||||
|
||||
|
||||
def getInt(key):
|
||||
return int(params[key])
|
||||
|
||||
|
||||
def _str2bool(v):
|
||||
return v.lower() in ("yes", "true", "t", "1")
|
||||
|
||||
|
||||
def getBool(key):
|
||||
return _str2bool(params[key])
|
||||
|
||||
|
||||
def flaskapp():
|
||||
return params[FLASK_APP]
|
||||
|
|
|
|||
|
|
@ -1,115 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Created with https://app.quicktype.io
|
||||
# name: stacosys
|
||||
|
||||
json_schema = """
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-06/schema#",
|
||||
"$ref": "#/definitions/Welcome",
|
||||
"definitions": {
|
||||
"Welcome": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"general": {
|
||||
"$ref": "#/definitions/General"
|
||||
},
|
||||
"http": {
|
||||
"$ref": "#/definitions/HTTP"
|
||||
},
|
||||
"security": {
|
||||
"$ref": "#/definitions/Security"
|
||||
},
|
||||
"rss": {
|
||||
"$ref": "#/definitions/RSS"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"general",
|
||||
"http",
|
||||
"rss",
|
||||
"security"
|
||||
],
|
||||
"title": "Welcome"
|
||||
},
|
||||
"General": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"debug": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"lang": {
|
||||
"type": "string"
|
||||
},
|
||||
"db_url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"db_url",
|
||||
"debug",
|
||||
"lang"
|
||||
],
|
||||
"title": "General"
|
||||
},
|
||||
"HTTP": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"root_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"host": {
|
||||
"type": "string"
|
||||
},
|
||||
"port": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"host",
|
||||
"port",
|
||||
"root_url"
|
||||
],
|
||||
"title": "HTTP"
|
||||
},
|
||||
"RSS": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"proto": {
|
||||
"type": "string"
|
||||
},
|
||||
"file": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"file",
|
||||
"proto"
|
||||
],
|
||||
"title": "RSS"
|
||||
},
|
||||
"Security": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"salt": {
|
||||
"type": "string"
|
||||
},
|
||||
"secret": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"salt",
|
||||
"secret"
|
||||
],
|
||||
"title": "Security"
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue