Skip to main content
Top

Web Application Development with Streamlit

Develop and Deploy Secure and Scalable Web Applications to the Cloud Using a Pure Python Framework

  • 2022
  • Book

About this book

Transition from a back-end developer to a full-stack developer with knowledge of all the dimensions of web application development, namely, front-end, back-end and server-side software. This book provides a comprehensive overview of Streamlit, allowing developers and programmers of all backgrounds to get up to speed in as little time as possible.

Streamlit is a pure Python web framework that will bridge the skills gap and shorten development time from weeks to hours. This book walks you through the complete cycle of web application development, from an introductory to advanced level with accompanying source code and resources. You will be exposed to developing basic, intermediate, and sophisticated user interfaces and subsequently you will be acquainted with data visualization, database systems, application security, and cloud deployment in Streamlit.

In a market with a surplus demand for full stack developers, this skill set could not possibly come at a better time. In one sentence, Streamlit is a means for the empowerment of developers everywhere and all stand to gain from it.

What You’ll Learn

Mutate big data in real-timeVisualize big data interactivelyImplement web application security and privacy protocols Deploy Streamlit web applications to the cloud using Streamlit, Linux and Windows servers

Who is this Book for?

Developers with solid programming experience wanting to learn Streamlit; Back-end developers looking to upskill and transition to become a full-stack developers; Those who wish to learn and become more acquainted with data visualization, database systems, security and cloud deployment with Steamlit

Table of Contents

  1. Frontmatter

  2. Chapter 1. Getting Started with Streamlit

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    Getting Started with Streamlit delves into the benefits of cloud computing and the role of Streamlit as a pure Python web framework. It compares Streamlit with legacy frameworks like Flask and Django, emphasizing Streamlit's ease of use and rapid development capabilities. The chapter also covers the installation and basic usage of Streamlit, setting the stage for more advanced topics in subsequent chapters.
  3. Chapter 2. Streamlit Basics

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter introduces the basics of Streamlit, a powerful tool for creating web applications. It covers essential techniques such as creating input forms, implementing conditional flow, managing errors, and mutating dataframes. Additionally, it demonstrates how to render static and interactive charts, and develop user interfaces. The chapter concludes with a summary of the key concepts and a preview of more advanced topics to come. By the end of this chapter, readers will be equipped with the skills to create and deploy their own web applications using Streamlit.
  4. Chapter 3. Architecting the User Interface

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into the architecture and customization of user interfaces in Streamlit, a powerful framework for developing web applications. It discusses how Streamlit allows developers to focus on backend logic while the framework handles the frontend implementation. The chapter covers the customization of color schemes, fonts, and layouts both programmatically and graphically, enabling the creation of bespoke user interfaces. Additionally, it explores advanced features such as placeholders for dynamic content, progress bars for real-time updates, and the creation of multipage and subpage applications. The chapter also provides best practices for folder structuring and modularizing application development, making it a valuable resource for developers looking to create efficient and scalable Streamlit applications.
  5. Chapter 4. Data Management and Visualization

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into the essential methods for managing and visualizing big data in web applications. It covers the encoding of large multimedia files and dataframes into bytes data for robust storage, leveraging Streamlit’s caching capabilities to enhance execution efficiency, and demonstrating the utility of the Plotly library for creating interactive and visually appealing charts. By providing hands-on techniques and examples, this chapter equips professionals with the tools necessary to handle and visualize data effectively, ensuring both efficiency and robustness in their applications.
  6. Chapter 5. Database Integration

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into the essentials of database integration, focusing on relational and nonrelational systems. It begins with an introduction to SQL and relational databases, using PostgreSQL as the primary tool. The chapter covers the basic CRUD operations and demonstrates how to connect PostgreSQL to Streamlit for data visualization and manipulation. Additionally, it explores advanced features like fuzzy matching and full-text indexing. The second half of the chapter introduces MongoDB, a popular nonrelational database, and shows how to integrate it with Streamlit for handling unstructured data. The chapter concludes with practical examples and code snippets, making it a valuable resource for professionals looking to enhance their data management skills.
  7. Chapter 6. Leveraging Backend Servers

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into the importance of backend servers in web application development, emphasizing the need to offload database management from the frontend to enhance security and modularity. It covers the fundamentals of frontend-backend communication, focusing on HTTP protocols and methods. The chapter also introduces JSON as a widely used data format in APIs and demonstrates how to build a Pythonic backend server using Flask. Additionally, it explores techniques for optimizing application performance through multiprocessing and multithreading. The chapter concludes with a practical example of connecting a Streamlit application to a backend server, showcasing the end-to-end process of building a secure and efficient web application architecture.
  8. Chapter 7. Implementing Session State

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    The chapter delves into the crucial aspect of implementing session state in Streamlit applications, which is essential for developing more advanced and user-friendly applications. It covers the native method introduced in Streamlit version 0.84.1 for managing session-specific data, including variables, widgets, and objects. The chapter also explores the use of cookies for storing state across multiple sessions, ensuring a seamless user experience. Additionally, it introduces session IDs to provide personalized experiences and demonstrates how to store session state persistently using a PostgreSQL database, enabling the retrieval of historical states and generating user insights. Practical examples and code listings are provided to illustrate these concepts, making the chapter a valuable resource for developers looking to enhance their Streamlit applications.
  9. Chapter 8. Authentication and Application Security

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    The chapter begins by introducing the necessity of secure user authentication for a production-ready Streamlit web application. It delves into the creation of admin accounts, password hashing using Bcrypt, and the implementation of JWTs for stateless authentication. The middleware is developed to intercept and authenticate requests, ensuring that only authorized users can access sensitive data. Additionally, the chapter highlights best practices for securing application secrets and preventing SQL injection attacks. The final sections discuss the importance of managing secrets securely and configuring Git to exclude sensitive files from version control. This chapter provides a thorough and practical approach to enhancing the security of web applications, making it a valuable resource for developers aiming to build robust and secure software solutions.
  10. Chapter 9. Deploying Locally and to the Cloud

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into the intricacies of deploying Streamlit applications, both locally and to the cloud. It begins by explaining how to expose a local Streamlit application to the Web, including methods like port forwarding and HTTP tunneling using Ngrok. The chapter then transitions to cloud deployment, focusing on Streamlit Cloud, which simplifies the process to a single click. Additionally, it covers secure data storage using Streamlit’s Secrets Management and provides comprehensive guides for deploying applications on Linux containers and Windows Server. Throughout, the chapter offers practical examples and detailed instructions, making it an invaluable resource for anyone looking to expand the reach of their Streamlit applications.
  11. Chapter 10. Building Streamlit Components

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    The chapter 'Building Streamlit Components' delves into the process of creating tailored components in Streamlit using ReactJS. It begins by explaining the basics of integrating ReactJS components into Streamlit applications, highlighting the flexibility and power of this approach. The chapter then walks through the steps to build, use, and share custom components within a Pythonic context, demonstrating how to enhance the user interface and functionality of Streamlit applications. Additionally, it covers advanced topics such as bidirectional data communication between Streamlit and ReactJS components, publishing components as pip packages, and showcasing a collection of intricate Streamlit components from the Extra-Streamlit-Components library. The chapter is particularly valuable for developers looking to extend the capabilities of their Streamlit applications with custom components, offering practical examples and insights into best practices.
  12. Chapter 11. Streamlit Use Cases

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    The chapter begins by introducing several use cases of Streamlit, such as data visualization and real-time dashboards. It then delves into more advanced applications, including interfacing with external devices like Arduino and sensors for real-time data collection and control. Additionally, the chapter covers the development of a data warehousing application using Streamlit and concludes with a comprehensive guide to creating a machine learning application as a service. Each section is designed to provide practical insights and code examples, making it a valuable resource for professionals looking to expand their skills in web development and data science.
  13. Chapter 12. Streamlit at Work

    Mohammad Khorasani, Mohamed Abdou, Javier Hernández Fernández
    This chapter delves into two compelling real-world applications of Streamlit, showcasing its potential in diverse industries. The first case study focuses on Iberdrola, a leading renewable energy firm, which leverages Streamlit to develop a data manager application for wind farms. This application enables the estimation of electrical losses and provides valuable insights from SCADA data, streamlining operational performance analysis. The second case study involves maxon Group, a manufacturer of high-precision electronic motors, which utilizes Streamlit to create a command and control dashboard for a surgical scope adapter system. This dashboard allows for real-time monitoring and remote control of motors, demonstrating the flexibility and power of Streamlit in industrial applications. Both case studies underscore the practical benefits and broad applicability of Streamlit in enhancing data management, visualization, and control systems, making it an invaluable tool for professionals across various sectors.
  14. Backmatter

Title
Web Application Development with Streamlit
Authors
Mohammad Khorasani
Mohamed Abdou
Javier Hernández Fernández
Copyright Year
2022
Publisher
Apress
Electronic ISBN
978-1-4842-8111-6
Print ISBN
978-1-4842-8110-9
DOI
https://doi.org/10.1007/978-1-4842-8111-6

Accessibility information for this book is coming soon. We're working to make it available as quickly as possible. Thank you for your patience.

Premium Partner

    Image Credits
    Neuer Inhalt/© ITandMEDIA, Nagarro GmbH/© Nagarro GmbH, AvePoint Deutschland GmbH/© AvePoint Deutschland GmbH, AFB Gemeinnützige GmbH/© AFB Gemeinnützige GmbH, USU GmbH/© USU GmbH, Ferrari electronic AG/© Ferrari electronic AG