a little work on new site system
This commit is contained in:
parent
9a35619a0b
commit
c237efd523
@ -33,18 +33,22 @@ from onionrutils import mnemonickeys
|
|||||||
site_api = Blueprint('siteapi', __name__)
|
site_api = Blueprint('siteapi', __name__)
|
||||||
|
|
||||||
@site_api.route('/site/<name>', endpoint='site')
|
@site_api.route('/site/<name>', endpoint='site')
|
||||||
def site(name):
|
def site(name: str)->Response:
|
||||||
bHash = name
|
"""Accept a site 'name', if pubkey then show multi-page site, if hash show single page site"""
|
||||||
resp = 'Not Found'
|
resp: str = 'Not Found'
|
||||||
if '-' in name:
|
|
||||||
|
# If necessary convert the name to base32 from mnemonic
|
||||||
|
if mnemonickeys.DELIMITER in name:
|
||||||
name = mnemonickeys.get_base32(name)
|
name = mnemonickeys.get_base32(name)
|
||||||
|
|
||||||
|
# Now make sure the key is regardless a valid base32 format ed25519 key (readding padding if necessary)
|
||||||
if stringvalidators.validate_pub_key(name):
|
if stringvalidators.validate_pub_key(name):
|
||||||
name = unpaddedbase32.repad(name)
|
name = unpaddedbase32.repad(name)
|
||||||
|
resp = findsite.find_site(name)
|
||||||
|
|
||||||
|
if stringvalidators.validate_hash(name):
|
||||||
if stringvalidators.validate_hash(bHash):
|
|
||||||
try:
|
try:
|
||||||
resp = onionrblockapi.Block(bHash).bcontent
|
resp = onionrblockapi.Block(name).bcontent
|
||||||
except onionrexceptions.NoDataAvailable:
|
except onionrexceptions.NoDataAvailable:
|
||||||
abort(404)
|
abort(404)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user