Component Libraries •
Project Templates
Docs •
Install •
Tutorials •
Developer Guides •
Contribute •
Blog •
Discord
Xircuits Component Library for Flask! Simplify building and managing web applications with seamless integration.
A comprehensive suite of components designed for creating and managing web applications using Flask within the Xircuits environment.
Before you begin, you will need the following:
- Python3.9+.
- Xircuits.
Initializes a Flask application, allowing customization of public paths, static URL paths, and secret key settings for enhanced flexibility.
Starts the Flask application server, with options to configure debug mode, host address, and port number.
Defines a GET route in the Flask application, linking it to specific actions or components to handle incoming requests.
Defines a POST route in the Flask application, enabling execution of actions or components when POST requests are received.
Defines a PUT route in the Flask application, linking it to specific actions or components for handling PUT requests.
Renders dynamic HTML templates with the ability to pass variables for personalized content delivery.
Sends a plain text response to the client, ideal for returning simple messages or lightweight API data.
Returns structured JSON data, making it essential for APIs or applications requiring client-side data parsing.
Redirects users to a different URL, enabling seamless navigation and flow control within the web application.
We have provided an example workflow to help you get started with the Flask component library. Give it a try and see how you can create custom Flask components for your applications.
This example creates a Flask server using Xircuits, featuring two routes:
- POST
/echo
: Accepts JSON input, processes it, and returns the input as a plain text response. - GET
/greet
: Returns a JSON response with a greeting message.
It demonstrates inline route definitions and dynamic request handling.
This example sets up a Flask server with multiple routes:
- GET
/hello/<name>
: Displays the path parameter<name>
in a structured response. - POST
/hello/<name>
: Accepts JSON input and returns it as a JSON response. - GET
/stream
: Streams a response to the client in chunks, demonstrating real-time data streaming. - PUT
/<some>/<path>/<parameters>
: Processes path parameters and prints them for debugging. - Interval Job: Prints a message every 5 seconds using a background job scheduler.
It showcases both route definitions and advanced Flask features like streaming and scheduled tasks.
To use this component library, ensure that you have an existing Xircuits setup. You can then install the Flask library using the component library interface, or through the CLI using:
xircuits install flask
You can also install it manually by cloning and installing it:
# base Xircuits directory
git clone https://github.com/XpressAI/xai-flask xai_components/xai_flask
pip install -r xai_components/xai_flask/requirements.txt