Web App Development Made Simple with Streamlit: A web developer's guide to effortless web app development, deployment, and scalability
()
Related to Web App Development Made Simple with Streamlit
Related ebooks
Building LLM Powered Applications: Create intelligent apps and agents with large language models Rating: 0 out of 5 stars0 ratingsAI-Assisted Programming for Web and Machine Learning: Improve your development workflow with ChatGPT and GitHub Copilot Rating: 0 out of 5 stars0 ratingsBuilding AI Applications with OpenAI APIs: Leverage ChatGPT, Whisper, and DALL-E APIs to build 10 innovative AI projects Rating: 0 out of 5 stars0 ratingsCoding with ChatGPT and Other LLMs: Navigate LLMs for effective coding, debugging, and AI-driven development Rating: 0 out of 5 stars0 ratingsFastAPI Cookbook: Develop high-performance APIs and web applications with Python Rating: 0 out of 5 stars0 ratingsGenerative AI Foundations in Python: Discover key techniques and navigate modern challenges in LLMs Rating: 0 out of 5 stars0 ratingsThe Art of AI Scrum Master & Work Rating: 0 out of 5 stars0 ratingsAI for Beginners: A Simple Guide to Artificial Intelligence and Machine Learning Rating: 0 out of 5 stars0 ratingsGenerative AI - From Big Picture, To Idea, To Implementation Rating: 0 out of 5 stars0 ratings.NET MAUI Cookbook: Build a full-featured app swiftly with MVVM, CRUD, AI, authentication, real-time updates, and more Rating: 0 out of 5 stars0 ratingsUnderstand IT: Starting From Scratch, #1 Rating: 0 out of 5 stars0 ratingsThe Art of AI Business Analyst & Work Rating: 0 out of 5 stars0 ratingsFull-Stack Web Development with TypeScript 5: Craft modern full-stack projects with Bun, PostgreSQL, Svelte, TypeScript, and OpenAI Rating: 0 out of 5 stars0 ratingsThe Art of AI Project Management & Work Rating: 0 out of 5 stars0 ratingsBuilding the Future: Advanced Web Development Techniques with Flask and Python Rating: 0 out of 5 stars0 ratingsUX for Enterprise ChatGPT Solutions: A practical guide to designing enterprise-grade LLMs Rating: 0 out of 5 stars0 ratingsAI In a Weekend An Executive's Guide Rating: 0 out of 5 stars0 ratingsArtificial Intelligence (AI) Unleashed Rating: 0 out of 5 stars0 ratingsUltimate Web API Development with Django REST Framework Rating: 0 out of 5 stars0 ratingsAI: A Practical Guide for Entrepreneurs Rating: 0 out of 5 stars0 ratingsZero to AI Hero: Build Working Apps Without Programming Skills Rating: 0 out of 5 stars0 ratingsAI Empire: The Future of Work is AI Build Your Home-Based Empire Rating: 0 out of 5 stars0 ratingsWanted Digital Skills: Coding, Programming and Creating Your First Websites and Apps: Wanted Digital Skills, #1 Rating: 0 out of 5 stars0 ratings
Internet & Web For You
Coding For Dummies Rating: 5 out of 5 stars5/5Coding with AI For Dummies Rating: 1 out of 5 stars1/5Six Figure Blogging Blueprint Rating: 5 out of 5 stars5/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5Surveillance and Surveillance Detection: A CIA Insider's Guide Rating: 3 out of 5 stars3/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5No Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5How To Start A Profitable Authority Blog In Under One Hour Rating: 5 out of 5 stars5/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsThe Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/5Beginner's Guide To Starting An Etsy Print-On-Demand Shop Rating: 0 out of 5 stars0 ratingsSocial Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Blogging For Dummies Rating: 0 out of 5 stars0 ratingsHTML in 30 Pages Rating: 5 out of 5 stars5/5Cybersecurity For Dummies Rating: 5 out of 5 stars5/5Ethical Hacking 101 - How to conduct professional pentestings in 21 days or less!: How to hack, #1 Rating: 5 out of 5 stars5/5The $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 4 out of 5 stars4/5Introduction to Internet Scams and Fraud: Credit Card Theft, Work-At-Home Scams and Lottery Scams Rating: 4 out of 5 stars4/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5Content Chemistry: The Illustrated Handbook for Content Marketing Rating: 5 out of 5 stars5/5IAPP CIPP/US Certification A Practical Study Guide to Master the Certified Information Privacy Professional Exam Rating: 0 out of 5 stars0 ratings
Reviews for Web App Development Made Simple with Streamlit
0 ratings0 reviews
Book preview
Web App Development Made Simple with Streamlit - Rosario Moscato
Web App Development Made Simple with Streamlit
Copyright © 2024 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rohit Rajkumar
Publishing Product Manager: Chayan Majumdar
Book Project Manager: Sonam Pandey
Senior Editor: Anuradha Joglekar
Technical Editor: K Bimala Singha and Simran Haresh Udasi
Copy Editor: Safis Editing
Proofreader: Safis Editing
Indexer: Pratik Shirodkar
Production Designer: Jyoti Kadam
DevRel Marketing Coordinators: Namita Velgekar and Nivedita Pandey
Publication date: February 2024
Production reference: 1110124
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK
ISBN 978-1-83508-631-5
www.packtpub.com
This book was in progress for a long time, and I would like to thank all my e-students for supporting me and pushing me to turn video lessons into pages. I would also to thank my kids, Liv and Giu, for motivating me to be a role model, and my parents for inspiring me to do great things and keep moving forward toward a noble target, come what may!
- Rosario Moscato
Contributors
About the author
Rosario Moscato has a master’s degree in electronic engineering (Federico II University, Naples) as well as a master’s degree in internet software design (CEFRIEL, Milan). He also has a diploma in apologetics (Pontifical Athenaeum Regina Apostolorum, Rome) and a master’s degree in science and faith (Pontifical Athenaeum Regina Apostolorum, Rome). Rosario has gained about 25 years of experience, always focusing his attention on the development and fine-tuning of the most innovative technologies in various international companies in Europe and Asia, covering various highly technical, commercial, and business development roles.
In recent years, his interest has focused exclusively on artificial intelligence and data science, pursuing, on the one hand, the goal of enhancing and making every business extremely competitive by introducing and supporting machine and deep learning technologies, and on the other hand, analyzing the ethical-philosophical implications deriving from the new scenarios that these disciplines open up. Rosario has authored two books, and he is a speaker at international research centers and conferences as well as a trainer and technical/scientific consultant on the huge and changing world of AI. Currently, he is working as a CTO with one of the oldest AI companies in Italy.
About the reviewers
Alessio Ligios is a dynamic data scientist, renowned for his proficiency in data analysis and machine learning. With a solid foundation in science and engineering, Alessio excels in transforming intricate data into practical business solutions. In his current role at Live Tech - Amplify your Data, Alessio has demonstrated his expertise by developing and implementing advanced textual content classification models. He excels in predictive modeling, leveraging machine learning (ML) and deep learning (DL) algorithms for accurate trend forecasting. Educationally, Alessio holds a master’s degree in computer science from Università degli Studi Roma Tre
with a distinguished vote of 110/110.
Corrado Silvestri is a computer engineer. He earned a master’s degree from Roma Tre
University with a GPA of 100/110. Passionate about the realm of AI and ML, he has produced models and projects of many types, such as forecasting, NLP, and computer vision, establishing the groundwork for his present position as a data scientist at a company that is verticalized in AI. An expert in the analytical phase and data manipulation, he has implemented AI models and solutions, expanding his technical experience and excelling in this field. He is a specialist at finding the perfect compromise by combining engineering expertise, data manipulation, and AI to build cutting-edge solutions for businesses in a variety of industries.
Table of Contents
Preface
Part 1: Getting Started with Streamlit
1
Getting to Know Streamlit – A Brief Overview
The importance of turning an idea into a prototype – the changing scenario in computing methods
The importance of a full Python web framework
Local versus the cloud
Python libraries for web applications (Flask and Django)
Examples of Streamlit’s capabilities
The importance of turning an idea into a prototype
Summary
2
Setting Up the Python Coding Environment
Technical requirements
Setting up the OS
IDE selection
What is a virtual environment?
Summary
3
Exploring Streamlit’s Features and Functionality
Technical requirements
Installing and launching Streamlit
Streamlit features and widgets
Colored textboxes
Images, audio, and video
Inputting text and numbers
Slider
Balloons
DataFrames, plots, and visualizations
Date, time, and more
Summary
Part 2: Building a Basic Web App for Essential Streamlit Skills
4
Streamlit Essentials – Configuring the Environment, Managing Packages, and More
Technical requirements
Configuring our environment
Installing and importing packages
App skeleton building
Building the menu and adding decorations
Summary
5
Organizing and Displaying Content with Columns, Expanders, and NLP Techniques
Technical requirements
Organizing and arranging content in a web app
Adding decorations
Adding the Text Analysis part
Hiding and showing parts depending on importance
Adding columns, expanders, and a textbox
Adding the two basic functions
Adding a wordcloud
Introducing NLP concepts – tokens and lemmas
Adding the summarization function
Tokens and lemmas
Using the text_analysis function
Summary
6
Implementing NLP Techniques for Text Analysis and Processing in Streamlit
Technical requirements
Deep-diving into NLP techniques
What is translation?
What is sentiment analysis?
Deep-diving into language translation
Adding a text area
Performing the translation task
Diving deep into sentiment analysis
Recap of our first web application
Summary
7
Sharing and Deploying Your Apps on the Cloud Using Streamlit Share
Technical requirements
Understanding the importance of deployment
Best practices in web application deployment
Additional benefits of web application deployment
What are Streamlit Share and Streamlit Cloud?
A quick introduction to GitHub
Getting familiar with the Streamlit Share service
Summary
Part 3: Developing Advanced Skills with a Covid-19 Detection Tool
8
Advanced Environment Setup and Package Management for Building an AI-Powered Web App
Technical requirements
Configuring our environment
Installing and importing packages
Building the app skeleton
Building the menu and adding decorations
Summary
9
Optimizing Streamlit Web App UX with Customization and UI Features
Technical requirements
Dealing with more advanced web app features
Adding the Image Enhancement section using the Pillow library
Contrast
Brightness
Original
Adding the Disclaimer and Info section
Summary
10
Utilizing Pretrained Models to Create Specialized and Personalized Web Applications
Technical requirements
Understanding the benefits of pretrained ML models
Creating customized web apps to improve user experience
Utilizing predictions from ML
Summary
11
Deploying and Managing Complex Libraries on Streamlit Share
Technical requirements
Consolidating cloud deployment skills
Avoiding bad behavior
Creating a list of all the packages that were installed and used to develop the Python code
Creating a GitHub repository
Avoiding runtime errors
Managing difficult libraries
Deploying the app on Streamlit Cloud
Summary
Part 4: Advanced Techniques for Secure and Customizable Web Applications
12
Smart File Uploading – Advanced Techniques for Professional Web Applications
Technical requirements
Understanding the customized features of the file uploader
Creating a new virtual environment
Building the app skeleton
Creating a radio button for the app menu
Creating a suitable file uploader for web apps
Simplifying web apps with smart components
Summary
13
Creating a Secure Login and Signup Process for Web Applications
Technical requirements
Understanding the logic behind the login and signup page
What is SHA-256 and why should we use it?
Connecting to a relational database and interacting with it
Creating the Login menu
Creating the Sign Up menu
Running the app
Adding a graphical user interface
Retrieving or saving credentials from and to the database
Summary
14
Customizing Pages, Personalizing Themes, and Implementing Multi-Pages
Technical requirements
Understanding new features related to deep customization
Creating deeply customized pages
Understanding theming and .toml files
Exploring the multi-pages feature
Creating multi-pages
Passing a variable from one page to another
Summary
15
Enhancing Web Apps with Forms, Session State, and Customizable Subdomains
Technical requirements
What are forms and when and why do we use them?
The context manager approach
The classic approach
What is Session State and when do we use it?
What are customizable subdomains and what possibilities do they offer?
Summary
16
Takeaways and Conclusion
How and when to use our web app working template
How and when to use databases and advanced skills
How to deploy web applications on the cloud
Farewell!
Index
Other Books You May Enjoy
Preface
In the swiftly evolving landscape of web application development, the desire to transform innovative ideas into functional web apps has never been more pressing. Web App Development Made Simple with Streamlit is a book that emerges as a beacon for those who seek to navigate this dynamic domain with ease and confidence. This book is meticulously crafted for a diverse range of professionals who share a common goal – the rapid transformation of code into working web applications.
At its core, Web App Development Made Simple with Streamlit is more than just a guide; it’s a journey. It takes you from the fundamentals of Streamlit, a powerful tool that simplifies web app development, to the intricate processes of deploying your solutions on cloud services. This journey is designed to be accessible, empowering you to make your applications available to a vast, global audience with minimal hassle.
Throughout the book, you’ll find a harmonious blend of theoretical knowledge and practical application. The chapters are structured to provide a clear, step-by-step guide, ensuring that even those new to web development can follow along with ease. Moreover, the book is peppered with real-world examples and case studies, providing you with a tangible understanding of how Streamlit can be leveraged in various scenarios.
As you delve into the pages of this book, expect to embark on a transformative learning experience. You’ll gain not just the skills to develop web applications but also the vision to see the potential of your code in the digital world. This book is your companion in unlocking the power of Streamlit, simplifying web app development, and bringing your ideas to the global stage.
Who this book is for
This book is tailored for Python programmers looking to transform their scripts into interactive web applications. It’s an essential resource for web developers seeking to streamline their prototyping process using Streamlit’s intuitive framework. Computer science students will find this book a practical guide for applying their theoretical knowledge to real-world web app development. IT professionals and enthusiasts eager to explore the realm of web app creation, especially those keen on deploying applications quickly and efficiently, will discover invaluable insights within these pages. Essentially, this book is a comprehensive toolkit for anyone passionate about bringing web app ideas to life with simplicity and speed.
What this book covers
Chapter 1, Getting to Know Streamlit – A Brief Overview, introduces Streamlit’s role in web app development. The chapter offers an overview of Streamlit’s user-friendly features and capabilities, as well as insight into rapid development with Streamlit.
Chapter 2, Setting Up the Python Coding Environment, includes a step-by-step guide for Python environment setup. The chapter includes tips for efficient Streamlit integration and focuses on creating a streamlined development workflow.
Chapter 3, Exploring Streamlit’s Features and Functionality, explores Streamlit’s functionalities in detail. Practical examples showcasing its versatility are included. The chapter also offers insights into Streamlit’s unique feature set.
Chapter 4, Streamlit Essentials – Configuring the Environment, Managing Packages, and More, describes key techniques for Streamlit environment configuration as well as best practices for efficient package management. Tips for optimizing the Streamlit setup are included.
Chapter 5, Organizing and Displaying Content with Columns, Expanders, and NLP Techniques, explores strategies for content organization using Streamlit’s tools. The chapter introduces natural language processing (NLP) techniques for enhanced content management and describes methods for effective data presentation.
Chapter 6, Implementing NLP Techniques for Text Analysis and Processing in Streamlit, teaches you how to apply NLP for text analysis within Streamlit. A step-by-step guide for NLP integration and case studies showcasing NLP in web app development are included.
Chapter 7, Sharing and Deploying Your Apps on the Cloud Using Streamlit Share, describes instructions for cloud deployment using Streamlit Share. Tips for making apps accessible globally are included. The chapter also offers insights into cloud-based app sharing.
Chapter 8, Advanced Environment Setup and Package Management for Building an AI-Powered Web App, teaches you advanced setup techniques for AI-driven web apps. Package management for AI integration and strategies for setting up an efficient AI web app environment are explained in detail.
Chapter 9, Optimizing Streamlit Web App UX with Customization and UI Features, explains how to enhance user experience through Streamlit customization. The chapter also explores UI features for functional aesthetics. Techniques for UI-driven app optimization are described.
Chapter 10, Utilizing Pretrained Models to Create Specialized and Personalized Web Applications, delves into the integration of pretrained models in web apps. The chapter explains how to create specialized, user-centric applications. Personalization strategies using AI models are described.
Chapter 11, Deploying and Managing Complex Libraries on Streamlit Share, explores techniques for deploying complex libraries on Streamlit Share. Strategies for managing robust app performance and complex library integration are included.
Chapter 12, Smart File Uploading – Advanced Techniques for Professional Web Applications, explains advanced file uploading methods for professionalism. The chapter teaches you how to streamline file uploads for user ease and enhance web apps with efficient file management.
Chapter 13, Creating a Secure Login and Signup Process for Web Applications, shows you how to design secure authentication processes, ensure user data protection, and implement robust login/signup systems in web apps.
Chapter 14, Customizing Pages, Personalizing Themes, and Implementing Multi-Pages, describes techniques for unique page customization. The chapter teaches you how to personalize themes for brand identity and utilize multi-page layouts for complex apps.
Chapter 15, Enhancing Web Apps with Forms, Session State, and Customizable Subdomains, teaches you how to utilize forms and session states for dynamic content. The chapter also describes how to implement customizable subdomains for branding. Strategies for enhancing web apps with advanced features are explored.
Chapter 16, Takeaways and Conclusion, summarizes the book’s essential insights and what you have learned, reflecting on Streamlit’s impact on web app development and offering concluding thoughts on future trends.
To get the most out of this book
You will need an understanding of the basics of Python programming and the Linux Terminal.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Web-App-Development-Made-Simple-with-Streamlit. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: Let’s check whether pip is installed in our Ubuntu box.
A block of code is set as follows:
st.header(This is a header
)
st.subheader(This is a subheader
)
st.text(This is a simple text
)
st.write(This is a write dimension
)
Any command-line input or output is written as follows:
pip --version (or pip3 --version)
Bold: Indicates a new term, an important word, or words that you see on screen. For instance, words in menus or dialog boxes appear in bold. Here is an example: We have also completed the Text Analysis and About sections of the menu.
Tips or important notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.
If you are interested in becoming an author: If there is a topic that you have