def Page(): doc = document() with doc.head: link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css") link_("https://extra-uru1z3cxu.now.sh/css/extra.css") link_( "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" ) script_( 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js' ) script_('http://intercoolerjs.org/release/intercooler-1.2.2.js') with doc.body: with dom.div(cls=CENTER_FRAME) as CenterFrame: with dom.div(cls=CARD) as Card: with dom.form(UPLOAD_FORM_ATTRS) as UploadForm: dom.i(cls=UPLOAD_ICON, onclick='''$('#fileupload').click()''') dom.p("Find File", id=1, cls="text-gray-500 mt-4") dom.button("Upload", type="submit", cls=BUTTON) dom.input( cls="hidden", type="file", name="image", id="fileupload", onchange= '''$('#1').text(this.value.split("\\\\").pop(-1))''') with dom.div(id="there", cls=RESULT_CONTAINER) as ResultContainer: dom.span(id="here") #新增 return doc.render()
def page(): doc = document() with doc.head: link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css") link_("https://extra-uru1z3cxu.now.sh/css/extra.css") link_("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css") script_("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js") script_("http://intercoolerjs.org/release/intercooler-1.2.2.js") with doc.body: with dom.div(cls=CENTER_FRAME) as CenterFrame: with dom.form(FORM_ATTR): with dom.div(cls=LABEL_CARD): dom.label('Write down your mark here', cls="text-white text-xl") dom.input( cls=LABEL_INPUT, type='text', placeholder='your watermark text here', name='mk-text') with dom.div(cls=IMG_CARD): with dom.div(cls=IMG_FORM): dom.i(cls=UPLOAD_ICON, onclick='''$('#fileupload').click()''') dom.p("Find File", id="file", cls="text-gray-500 mt-4") dom.input(cls="hidden", type="file", name='bg-img', id="fileupload", onchange='''$('#file').text(this.value.split("\\\\").pop(-1))''') dom.button('Upload', cls=BUTTON, type='submit') with dom.div(cls=RESULT_CONTAINER, id="there") as ResultContainer: dom.span(id="here") return doc.render()
def page(): doc = document() with doc.head: link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css") link_("https://extra-uru1z3cxu.now.sh/css/extra.css") link_("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css") dom.script(src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js') with doc.body: with dom.div(cls=CENTER_FRAME)as CenterFrame: with dom.div(cls=CARD) as Card: with dom.form(cls=UPLOAD_FORM) as UploadForm: dom.i(cls=UPLOAD_ICON,onclick=''' $('#fileupload').click()''') dom.p("Find File",id =1,cls="text-gray-500 mt-4") dom.button("Upload",cls=BUTTON) dom.input(cls='hidden',type="file",id="fileupload",onchange=''' $('#1').text(this.value.split("\\\\").pop(-1))''') with dom.div(cls=RESULT_CONTAINER) as ResultContainer: for _ in range(4): with dom.div(cls=RESULT_ITEM) as ResultItem: dom.p("filename.jpg",cls="text-xl text-gray-400") dom.i(cls="fas fa-download text-xl text-gray-400") with dom.div() as ResultContainer: pass return doc.render()
def page(): doc = document() with doc as root: with doc.body: ## form input button;input三个属性:type,name,value with dom.form(action="/file", method="post", enctype="multipart/form-data"): dom.input(type="file", name="image") dom.button("submit", type="submit") return root.render()
def page(): doc = document() with doc as root: with doc.body: with dom.form(action='/file', method='post', enctype='multipart/form-data'): dom.input(type='file', name='image') dom.button('提交', type='submit') return root.render()
def __init__(self, web_dir, title, refresh=0): self.title = title self.web_dir = web_dir self.img_dir = os.path.join(self.web_dir, 'images') if not os.path.exists(self.web_dir): os.makedirs(self.web_dir) if not os.path.exists(self.img_dir): os.makedirs(self.img_dir) self.doc = document(title=title) if refresh > 0: with self.doc.head: meta(http_equiv="refresh", content=str(refresh))
def bootstrapDoc(): #{{{ doc = document(title='My Title') doc.head.add(meta(name="viewport", content="width=device-width, initial-scale=1.0")) doc.head.add(comment('Latest compiled and minified CSS')) doc.head.add(link(rel="stylesheet", href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css")) content = doc.body.add(div(_class="container", id="content")) scripts = doc.body.add(div(_class='container', id="scripts")) scripts.add(comment('jQuery library')) scripts.add(script(src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js')) scripts.add(comment('Latest compiled JavaScript')) scripts.add(script(src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js')) return doc
def page(): doc = document() with doc.head: link_("https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css") link_("https://extra-uru1z3cxu.now.sh/css/extra.css") link_( "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.css" ) dom.script( src= 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js' ) with doc.body: with dom.div(cls=CENTER_FRAME) as CenterFrame: with dom.form(action='/file', method='post', enctype='multipart/form-data'): with dom.div(cls=LABEL_CARD): dom.label('Write down your mark here', cls="text-white text-xl") dom.input(cls=LABEL_INPUT, type='text', placeholder='your watermark text here', name='mk-text') with dom.div(cls=IMG_CARD): with dom.div(cls=IMG_FORM): dom.i(cls=UPLOAD_ICON, onclick='''$('#fileupload').click()''') dom.p("Find File", id="file", cls="text-gray-500 mt-4") dom.input( cls="hidden", type="file", name='bg-img', id="fileupload", onchange= '''$('#file').text(this.value.split("\\\\").pop(-1))''' ) dom.button('Upload', cls=BUTTON, type='submit') with dom.div(cls=RESULT_CONTAINER) as ResultContainer: for _ in range(4): with dom.div(cls=RESULT_ITEM) as ResultItem: dom.p("filename.jpg", cls="text-xl text-gray-400") dom.i(cls="fas fa-download text-xl text-gray-400") return doc.render()
from dominate.document import document from dominate.tags import * css = "https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" doc = document() with doc: with doc.head: link(rel="stylesheet", href=css) with doc.body: attr(cls="bg-black") with doc: with div(cls="min-h-screen flex justify-center items-center flex-col"): img(src="https://file-hjvdnhtoxy.now.sh") with form(cls="flex mt-3"): attr(action='/result', method='post') input_( name="code", cls= "border-2 w-64 py-2 px-3 text-white text-4xl justify-center bg-black" ), button("SUBMIT", cls="bg-white py-2 px-3 text-4xl justify-center")
def __init__(self, result): """ This instantiates a Popup object from a single DataFrame row's data. That is the 1-index element in a single row from the method self.iterrows() Attributes: - name (str): the name of the business - phone (str): phone number - price (str): a Yelp-style price rating $, $$... - food_status (str): a comma-delimited string with one of: - 'pass': successful food inspection pass - 'pass w/ conditions': conditional pass - 'fail': failure - food_date (str): a comma-delimited string with inspection dates - wages_violations (str): a comma-delimited string with the number labour violations incurred by the establishment (from BLS data) - divvy_stations (str): a comma-delimited string with nearby divvy bicycle stations. - env_complaints (str): the number of environmental complaints registered against this business - env_complaints_url (str): the url of the csv file which details environmental complaints - env_enforce (str): the number of environmental enforcements levied against this business - env_enforce_url (str): the url of the csv file which details environmental enforcements - rendered_html (str): a string of which contains html code that will be passed into a javascript array. See self.to_html() - to_label (list of tuples): a list in the form: (attribute, prefix) """ result = check_is_Series(result) # ensure the right type ### REQUIRED FIELDS ### straight_no_default = ["name", "addr", "latitude", "longitude"] for i in straight_no_default: # loop through row's contents self.__dict__[i] = result[i] lists_to_be_joined = [ "food_status", "food_date", "wages_violations", "divvy_stations", "env_complaints", "env_complaints_url", "env_enforce", "env_enforce_url" ] ### FIELDS WHICH ARE LISTS ### # joined by ", " with none as the default for i in lists_to_be_joined: try: self.__dict__[i] = ", ".join(result[i]) except: self.__dict__[i] = None leftovers = ["phone", "price"] ### ITEMS WHICH REQUIRE NO ACTION, JUST ADD THEM TO OUTPUT #### # items which require no action, just add to the output for i in leftovers: try: self.__dict__[i] = result[i] except: self.__dict__[i] = None self.rendered_html = document() # This is a list of attributes and their specified prefix # this is what is written in to the popup self.to_label = [ (self.phone, ""), (self.price, ""), (self.food_status, "Food Inspections: "), (self.food_date, "Inspection Date: "), (self.wages_violations, "Recorded Bureau of Labor Violations: "), (self.divvy_stations, "Nearby Divvy Stations: "), (self.env_complaints, "Environmental Complaints: "), (self.env_complaints_url, "Complaints Links: "), (self.env_enforce, "Environmental Penalties Levied: "), (self.env_enforce_url, "Environmental Penalties Links: ") ]