mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-24 10:54:04 +08:00
add custom css kqarg
This commit is contained in:
parent
3647f5a04b
commit
9847fb087b
@ -1,9 +1,7 @@
|
||||
import gradio as gr
|
||||
import random
|
||||
import time
|
||||
|
||||
def calculator(num1, operation, num2):
|
||||
time.sleep(70)
|
||||
if operation == "add":
|
||||
return num1 + num2
|
||||
elif operation == "subtract":
|
||||
@ -21,8 +19,8 @@ iface = gr.Interface(calculator,
|
||||
[4, "divide", 2],
|
||||
[-4, "multiply", 2.5],
|
||||
[0, "subtract", 1.2],
|
||||
], auth=("admin", "admin")
|
||||
]
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch(share=True)
|
||||
iface.launch()
|
||||
|
@ -48,7 +48,7 @@ class Interface:
|
||||
layout="horizontal", show_input=True, show_output=True,
|
||||
capture_session=False, interpretation=None,
|
||||
title=None, description=None, article=None, thumbnail=None,
|
||||
server_port=None, server_name=networking.LOCALHOST_NAME,
|
||||
css=None, server_port=None, server_name=networking.LOCALHOST_NAME,
|
||||
allow_screenshot=True, allow_flagging=True,
|
||||
embedding=None, flagging_dir="flagged", analytics_enabled=True):
|
||||
|
||||
@ -68,6 +68,7 @@ class Interface:
|
||||
description (str): a description for the interface; if provided, appears above the input and output components.
|
||||
article (str): an expanded article explaining the interface; if provided, appears below the input and output components. Accepts Markdown and HTML content.
|
||||
thumbnail (str): path to image or src to use as display picture for models listed in gradio.app/hub
|
||||
css (str): custom css or path to custom css file to use with interface.
|
||||
server_name (str): to make app accessible on local network set to "0.0.0.0".
|
||||
allow_screenshot (bool): if False, users will not see a button to take a screenshot of the interface.
|
||||
allow_flagging (bool): if False, users will not see a button to flag an input and output.
|
||||
@ -127,6 +128,11 @@ class Interface:
|
||||
article = markdown2.markdown(article)
|
||||
self.article = article
|
||||
self.thumbnail = thumbnail
|
||||
if css is not None and os.path.exists(css):
|
||||
with open(css) as css_file:
|
||||
self.css = css_file.read()
|
||||
else:
|
||||
self.css = css
|
||||
self.examples = examples
|
||||
self.examples_per_page = examples_per_page
|
||||
self.server_port = server_port
|
||||
|
@ -99,7 +99,8 @@ def main():
|
||||
title=app.app_globals["title"],
|
||||
description=app.app_globals["description"],
|
||||
thumbnail=app.app_globals["thumbnail"],
|
||||
vendor_prefix=(GRADIO_STATIC_ROOT if app.interface.share else "")
|
||||
vendor_prefix=(GRADIO_STATIC_ROOT if app.interface.share else ""),
|
||||
css=app.interface.css
|
||||
)
|
||||
|
||||
|
||||
|
@ -61,6 +61,9 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/interfaces/output/json.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/interfaces/output/html.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/loading.css') }}"/>
|
||||
{% if css is not none %}
|
||||
<style>{{ css }}</style>
|
||||
{% endif %}
|
||||
</head>
|
||||
|
||||
<body id="lib">
|
||||
|
Loading…
Reference in New Issue
Block a user