This commit is contained in:
shao1chuan 2024-03-03 09:34:46 +08:00
parent 7e5810d745
commit aea2781f01
6 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,8 @@
import plotly.graph_objects as go
from nicegui import ui
fig = go.Figure(go.Scatter(x=[1, 2, 3, 4], y=[1, 2, 3, 2.5]))
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0))
ui.plotly(fig).classes('w-full h-40')
ui.run()

View File

@ -0,0 +1,19 @@
from fastapi import FastAPI
from nicegui import app, ui
def init(fastapi_app: FastAPI) -> None:
@ui.page('/')
def show():
ui.label('Hello, FastAPI!')
# NOTE dark mode will be persistent for each user across tabs and server restarts
ui.dark_mode().bind_value(app.storage.user, 'dark_mode')
ui.checkbox('dark mode').bind_value(app.storage.user, 'dark_mode')
ui.run_with(
fastapi_app,
mount_path='/gui', # NOTE this can be omitted if you want the paths passed to @ui.page to be at the root
storage_secret='pick your private secret here', # NOTE setting a secret is optional but allows for persistent storage per user
)

View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
import frontend
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get('/')
def read_root():
return {'Hello': 'World'}
frontend.init(app)
def main():
# 使用uvicorn运行FastAPI应用指定主机地址和端口
uvicorn.run(app, host="127.0.0.1", port=8000, log_level="info")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,5 @@
0 官网
https://nicegui.io/documentation
http://www.quasarchs.com/
1 视频教程
https://www.bilibili.com/video/BV1EM4y1x7CM/?spm_id_from=333.337.search-card.all.click&vd_source=311a862c74a77082f872d2e1ab5d1523

View File

@ -1,6 +1,6 @@
import pandas as pd
chipo = pd.read_csv("chipotle.tsv", sep = '\t')
chipo = pd.read_csv("chipotle.tsv", sep ='\t')
print(chipo.head(10),chipo.shape[1])
c = chipo[['item_name','quantity']].groupby(['item_name'],as_index=False).agg({'quantity':sum})