Skip to content
Dmitry Ponyatov edited this page Aug 19, 2019 · 5 revisions

WEB metaL интерфейс

#################################################################### ввод/вывод
class IO(Frame): pass
############################################################### сетевые функции

class Net(IO): pass

class IP(Net): pass

class Port(Net):
    def __init__(self,V):
        Net.__init__(self, int(V))
################################################################# web-интерфейс

class Web(Net):
    def __init__(self,V):
        Net.__init__(self, V)
        self['host'] = IP('127.0.0.1')
        self['port'] = Port(8888)
    def eval(self,ctx):
        flask = __import__('flask')
        app   = flask.Flask(self.val)
        
        @app.route('/')
        def index():
            return flask.render_template('index.html',ctx=ctx,web=self)
        
        @app.route('/<path:path>.css')
        def css(path):
            return flask.Response(\
                flask.render_template(path + '.css',ctx=ctx,web=self),\
                mimetype='text/css')
        
        app.run(host=self['host'].val,port=self['port'].val,debug=True)
################################################################# web-интерфейс

def WEB(ctx): ctx['WEB'] = Web('metaL') ; ctx['WEB'].eval(ctx)
glob << WEB
################################################################# инициализация
        
WEB(glob)
Clone this wiki locally