Beispiel #1
0
    def url(self, path="", lang=False):

        DS, p = "", ""
        self.Router = Router()
        seturl = self.out("HTTP_HOST")+str(":")+str(self.out("SERVER_PORT", '')) if self.out("HTTP_HOST") == "localhost" or self.out("HTTP_HOST") == "127.0.0.1" else self.out("HTTP_HOST")

        if self.out("HTTPS", "") == 'on':
            url = str("https://") + seturl.replace(":80", "") + "/" + self.Router.alllanguages.get(self.Router.getLanguages(), self.Router.getLanguages()) if lang == True else str(
                    "https://") + seturl.replace(":80", "") 
        else:

            url = str("http://") + seturl.replace(":80", "")+ "/" + self.Router.alllanguages.get(self.Router.getLanguages(), self.Router.getLanguages()) if lang == True else str("http://") + seturl.replace(":80", "")

        if path == "":
            DS = ""
        else:

            if path[:1] == "/":
                p = path[1:]
                DS = "/"
            else:
                p = path
                DS = "/"

        return url + DS + p
Beispiel #2
0
    def url(path="", lang=False):
        from pytonik.Router import Router
        from pytonik.util.Variable import Variable

        ront = Router()
        env_os = Variable()
        DS, p, url = "", "",  ""
        seturl = ront.out("HTTP_HOST")+str(":")+str(env_os.out("SERVER_PORT", '')) if env_os.out(
            "HTTP_HOST") == "localhost" or env_os.out("HTTP_HOST") == "127.0.0.1" else env_os.out("HTTP_HOST")

        if ront.out("HTTPS", "") == 'on':

            url = str("https://") + seturl.replace(":80", "") + "/" + ront.alllanguages.get(ront.getLanguages(), ront.getLanguages()) if lang == True else str(
                "https://") + seturl.replace(":80", "")
        else:
            url = str("http://") + seturl.replace(":80", "") + "/" + ront.alllanguages.get(ront.getLanguages(), ront.getLanguages()) if lang == True else str("http://") + seturl.replace(":80", "")

        if path == "":
            DS = ""
        else:
            if path[:1] == "/":
                p = path[1:]
                DS = "/"
            else:
                p = path
                DS = "/"

        return url + DS + p
Beispiel #3
0
    def url(self, path="", lang=False):

        ront = Router()
        seturl = str("localhost:") + str(os.environ.get("SERVER_PORT", ''))
        http = os.environ.get("HTTPS")
        if http == 'on':
            url = str("https://") + os.environ.get(
                "HTTP_HOST", seturl) + "/" + ront.alllanguages.get(
                    ront.getLanguages(),
                    ront.getLanguages()) if lang is True else str(
                        "https://") + os.environ.get("HTTP_HOST", seturl)
        else:
            url = str("http://") + os.environ.get(
                "HTTP_HOST", seturl) + "/" + ront.alllanguages.get(
                    ront.getLanguages(),
                    ront.getLanguages()) if lang is True else str(
                        "http://") + os.environ.get("HTTP_HOST", seturl)

        DS = ""
        p = ""

        if path == "":
            DS = ""
        else:
            if path[:1] == "/":
                p = path[1:]
                DS = "/"
            else:
                p = path
                DS = "/"

        return url + DS + p
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     self.langs = Lang(Router().getLanguages())
     self.langs.loadLang()
     if len(args) or len(kwargs):
         if all(args) is not False:
             self.lg = self.lang(*args, **kwargs)
         else:
             self.lg = self.lang(**kwargs)
     return None
Beispiel #5
0
def url(path="", lang=False):
    from pytonik.Router import Router
    import os
    ront = Router()
    dev_path = ""
    http_s = os.environ.get("HTTP_HOST")
    urlv = os.environ.get('REQUEST_URI', os.environ.get('PATH_INFO'))
    if http_s == "127.0.0.1" or http_s == "localhost":
        dev_path = str("/") + str(urlv).split('/')[1]
    else:
        dev_path = ""

    seturl = str("localhost:") + str(os.environ.get("SERVER_PORT", ''))
    http = os.environ.get("HTTPS")

    if http == 'on':
        url = str("https://") + os.environ.get(
            "HTTP_HOST", seturl) + str(dev_path) + "/" + ront.alllanguages.get(
                ront.getLanguages(), ront.getLanguages()
            ) if lang is True else str("https://") + os.environ.get(
                "HTTP_HOST", seturl) + str(dev_path)
    else:
        url = str("http://") + os.environ.get(
            "HTTP_HOST", seturl) + str(dev_path) + "/" + ront.alllanguages.get(
                ront.getLanguages(), ront.getLanguages()
            ) if lang is True else str("http://") + os.environ.get(
                "HTTP_HOST", seturl) + str(dev_path)

    DS = ""
    p = ""

    if path == "":
        DS = ""
    else:
        if path[:1] == "/":
            p = path[1:]
            DS = "/"
        else:
            p = path
            DS = "/"

    return url + DS + p
Beispiel #6
0
class url(Variable):
    def __getattr__(self, item):
        return item

    def __call__(self, *args, **kwargs):
        return None

    def __init__(self, *args, **kwargs):

        if len(args) > 0 or len(kwargs) > 0:

            if all(args) is not False:
                self.ul = self.url(*args, **kwargs)
            else:
                self.ul = self.url(**kwargs)
        else:
            self.ul = self.url(*args)
        return None

    def __str__(self):

        return self.ul

    def url(self, path="", lang=False):

        DS, p = "", ""
        self.Router = Router()
        seturl = self.out("HTTP_HOST")+str(":")+str(self.out("SERVER_PORT", '')) if self.out("HTTP_HOST") == "localhost" or self.out("HTTP_HOST") == "127.0.0.1" else self.out("HTTP_HOST")

        if self.out("HTTPS", "") == 'on':
            url = str("https://") + seturl.replace(":80", "") + "/" + self.Router.alllanguages.get(self.Router.getLanguages(), self.Router.getLanguages()) if lang == True else str(
                    "https://") + seturl.replace(":80", "") 
        else:

            url = str("http://") + seturl.replace(":80", "")+ "/" + self.Router.alllanguages.get(self.Router.getLanguages(), self.Router.getLanguages()) if lang == True else str("http://") + seturl.replace(":80", "")

        if path == "":
            DS = ""
        else:

            if path[:1] == "/":
                p = path[1:]
                DS = "/"
            else:
                p = path
                DS = "/"

        return url + DS + p
Beispiel #7
0
from pytonik.Router import Router

route = Router()

route.get("/")


Beispiel #8
0
from pytonik.Router import Router

route = Router()

route.any("/", "indexController@index:id")

route.get('index/login',
          route.args(params=['para', 'type', 'action'], to="login"))
route.get('index/register',
          route.args(params=['para', 'type', 'action'], to="register"))
route.get('index/cart', route.args(params=['para', 'type', 'action'],
                                   to="cart"))

route.get('index/dashboard',
          route.args(params=['para', 'type', 'action'], to="dashboard"))

route.get('index/address', route.args(params=['id', 'type'], to="address"))

route.get('index/product',
          route.args(params=['para', 'type', 'action'], to="product"))

route.get('index/product_detail',
          route.args(params=['product_para', 'action'], to="detail"))

route.get('index/order_history',
          route.args(params=['para', 'type', 'action'], to="order"))
route.get('index/add_address',
          route.args(params=['country_id', 'state_id'], to="add/address"))

route.get('index/forget_password',
          route.args(params=['para', 'type', 'action'], to="forget/password"))