Have you ever wanted to create a web application in only several lines of Python code? If you are looking for something that is easier to learn than Django and Flask, but more customizable than Streamlit, you will love PyWebIO.
PyWebIO is a Python library that allows you to build simple web applications without the knowledge of HTML and Javascript. The GIF above shows how some of the things you can do with PyWebIO.
2 thoughts on “PyWebIO: Write Interactive Web App in Script Way Using Python”
Hey Khuyen,
Thank you for this great tip. I attempted to try an example of the same, however the web page never really loads. Do you know why that could happen or how to fix that ?
“`python
import pandas as pd
from pywebio.input import file_upload
from pywebio.output import put_table, put_loading
from pywebio import start_server
import csv
import re
def app():
file = file_upload(label=’Upload your CSV file’, accept=’.csv’)
content = file[‘content’].decode(‘utf-8′).splitlines()
df = content_to_pandas(content)
create_profile(df)
def create_profile(df: pd.DataFrame):
put_table(df.to_dict())
def content_to_pandas(content: list):
with open(“tmp.csv”, “w”) as csv_file:
writer = csv.writer(csv_file, delimiter=’\t’)
for line in content:
writer.writerow(re.split(‘\s+’, line))
return pd.read_csv(“tmp.csv”)
if __name__ == ‘__main__’:
start_server(app, port=37791, debug=True)
“`

Regards
Uday
Hi Uday, try to remove port=37791 and see if it works. Then use the port the website is rendered at for the value of the port in the start_server() function.
Comments are closed.