平板折腾即

1,Qpython+MVC+WebEdit

2,AndroPHP

#qpy:webapp:Hello Qpython
#qpy://127.0.0.1:9090/
"""
This is a sample for qpython webapp
"""

from bottle import Bottle, ServerAdapter
from bottle import run, debug, route, error, static_file, template
import os
import re
Chas="Hello"

######### QPYTHON WEB SERVER ###############

class MyWSGIRefServer(ServerAdapter):
    server = None

    def run(self, handler):
        from wsgiref.simple_server import make_server, WSGIRequestHandler
        if self.quiet:
            class QuietHandler(WSGIRequestHandler):
                def log_request(*args, **kw): pass
            self.options['handler_class'] = QuietHandler
        self.server = make_server(self.host, self.port, handler, **self.options)
        self.server.serve_forever()

    def stop(self):
        #sys.stderr.close()
        import threading 
        threading.Thread(target=self.server.shutdown).start() 
        #self.server.shutdown()
        self.server.server_close() #<--- alternative but causes bad fd exception
        print("# qpyhttpd stop")


######### BUILT-IN ROUTERS ###############
@route('/__exit', method=['GET','HEAD'])
def __exit():
    global server
    server.stop()

@route('/__ping')
def __ping():
    return "ok"

##########MVC#############
def runsbf(Fl):
    text = Fl
    words = re.findall("\{(.+?)\}", text)
    return words
def divsbf(Fl):
    text = Fl
    return re.sub("\{[^\}]*\}","{}",text)

def GetsFbf(Fl):
    res = divsbf(Fl)
    Retus = runsbf(Fl)
    for retu in Retus:
        if retu[0] == '#':
            res = res.replace("{}","{"+retu[1:]+"}",1)
        elif retu[0] == '@':
            res = res.replace("{}",str(eval(retu[1:])),1)
        else:
            res = res.replace("{}","",1)
            exec(retu)
    return res

#################End#########

@route('/assets/<filepath:path>')
def server_static(filepath):
    #return static_file(filepath, root='/sdcard/qpython/scripts3/web')
    return GetsFbf(open("/sdcard/qpython/scripts3/web/"+filepath).read())

@route('/Runs/<filepath:path>')
def Runs(filepath):
    return os.popen(filepath).read().replace("\n","<br />")

@route('/Chat/<filepath:path>')
def Cha(filepath):
    Chas=Chas+filepath
    return Chas

######### WEBAPP ROUTERS ###############
@route('/')
def home():
    namm = 12
    asdf = "{namm}"
    return '<h1>Hello OIer !</h1>I Want to Use it to Build WordPress WebSite'


######### WEBAPP ROUTERS ###############
app = Bottle()
app.route('/', method='GET')(home)
app.route('/__exit', method=['GET','HEAD'])(__exit)
app.route('/__ping', method=['GET','HEAD'])(__ping)
app.route('/assets/<filepath:path>', method='GET')(server_static)
app.route('/Chat/<filepath:path>', method='GET')(Cha)
app.route('/Runs/<filepath:path>',method='GET')(Runs)

try:
    server = MyWSGIRefServer(host="0.0.0.0", port="9090")
    app.run(server=server,reloader=False)
except (Exception) as ex:
    print("Exception: %s" % repr(ex))

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇