#index.py
import sys
from routes.frontend import index
from routes.frontend import login

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

if sys.platform == 'win32':
    app.run(host='localhost', port=7000, debug=True, reloader=True)

 

#routes/frontend/login.py
from bottle import Bottle

app = Bottle()

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

 

#controllers/frontend/login/get.py
import config
from copy import deepcopy

def call():
    kdict = deepcopy(config.kdict)
    from . import createRootUser
    createRootUser.call()

 

#controllers/frontend/login/createRootUser.py
#pip install pymongo
#pip install bcrypt
import uuid, config, pymongo, bcrypt

def call():
    myclient = pymongo.MongoClient(config.kdict['MONGODB_URI'])
    mydb = myclient["multimedia"]
    mycol = mydb["users"]

    password = b"xxxxxxxxxxxxxxxxxxxxxx"
    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":""
     }

    mycol.insert_one(user)

 

GitHub: https://github.com/Sokhavuth/khmerweb-multimedia

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