View Source
{project_name}
")
if not subtitle:
with page.add_form(action="/project_detail") as form:
form.add_formhidden(name="project_name", value=project_name)
form.add_formhidden(name="compare_to", value=compare_to if compare_to else "")
form.add_formtext(name="subtitle", label="Subtitle", placeholder="Enter a subtitle")
form.add_formsubmit("Update Subtitle")
else:
page.add_header(f"{subtitle}", size=4)
if compare_to:
project_detail = pypi_projects_by_month[pypi_projects_by_month['pypi_project'].isin([project_name, compare_to])]
else:
project_detail = pypi_projects_by_month[pypi_projects_by_month['pypi_project'] == project_name]
fig = px.line(project_detail.sort_values(["month", "pypi_project"]), x="month", y="avg_downloads_per_day", line_group="pypi_project", color="pypi_project")
page.add_plotlyfigure(fig)
if not compare_to:
with page.add_card() as card:
with card.add_form(action="/project_detail") as form:
form.add_formhidden(name="project_name", value=project_name)
form.add_formtext(label="Compare To", name="compare_to", placeholder="Enter a project name")
form.add_formsubmit("Analyze")
return page.to_html()
@app.route('/view_source')
def view_source() -> str:
page = pv.Page("View Source")
page.add_header("View Source")
# Read the source code
with open(__file__, 'r') as f:
source = f.read()
# Add the source code to the page
page.add_codeeditor(source, language="python")
return page.to_html()
# RUN APP
if __name__ == '__main__':
app.run(debug=True)