#index.py
from routes import login
from routes.front import index

app = index.app
app.mount('/login', login.app)

import socket    
host = socket.getfqdn()    
addr = socket.gethostbyname(host)
if(addr == '127.0.1.1'):
   app.run(host='localhost', port=7000, debug=True, reloader=True)

 

#routes/login.py
from bottle import Bottle

app = Bottle()

@app.route('/')
def getForm():
    from controllers.login import get
    return get.call()

 

#controllers/login/get.py
import config
from copy import deepcopy
from bottle import template
from . import createRootUser

def call():
    kdict = deepcopy(config.kdict)
    kdict['pageTitle'] = 'ទំព័រ​ចុះ​ឈ្មោះ'
    kdict['route'] = '/login'

    createRootUser.call()

    return template('base',data=kdict)

 

#controllers/login/createRootUser.py
#pip install bcrypt
import uuid, config,bcrypt
from models import setDBconnection
 
def call():
    password = b"xxxxxxxxxx"
    hashedPassword = bcrypt.hashpw(password, bcrypt.gensalt())
 
    user = { 
        "userID": uuid.uuid4().hex, 
        "email": "root@khmerweb.app",
        "username": "root",
        "password": hashedPassword,
        "role":"Admin",
        "thumb":"",
        "info":"",
        "video":"",
        "date":""
     }
 
    doc_ref = setDBconnection.db.collection('users').document('root user')
    doc_ref.set(user)

 

Vercel: https://khmerweb-vlog.vercel.app

GitHub: https://github.com/Sokhavuth/vlog