forms.ioit.acm is a public-facing web application to display and render forms created in the ChapterOS. It uses a lightweight Flask backend to serve a React frontend, which then fetches form data from the ChapterOS API.
This application is one part of a two-part system:
-
ChapterOS (The "Admin" Backend):
- A separate application built with Django.
- Used by administrators to create, design, manage, and approve forms.
- It exposes a public, read-only API endpoint to share form structures:
https://os.ioit.acm.org/form_builder/api/forms/public/{slug}/schema/.
-
This Application (The "Public" Frontend):
- Built with Flask and React.
- Its primary role is to provide a clean, public URL for each form.
- When a user visits a URL like
http://localhost:9561/some-form-slug, this application's React frontend fetches the form's structure from the ChapterOS API and renders it for the user.
- The frontend is a Single Page Application (SPA) built with React, TypeScript, and styled with Tailwind CSS.
- The backend is a minimal Flask server whose main job is to serve the compiled React application files.
- When a user navigates to a URL with a slug (e.g.,
http://localhost:9561/my-form), Flask serves the base HTML file that loads the React application. - Once the React application loads in the browser, it extracts the
slug(my-form) directly from the URL using the browser'swindow.location.pathnameobject. - It then makes a
fetchrequest to the ChapterOS API endpoint (https://os.ioit.acm.org/form_builder/api/forms/public/my-form/schema/) to get the form's structure as JSON. - Finally, React dynamically renders the form on the page based on the received JSON data, or displays an appropriate message if the form is inactive or not found.
-
Install Dependencies:
# Install Python dependencies pip install -r requirements.txt # Install Node.js dependencies npm install
-
Build the Frontend: This command compiles the React/TS code and places the output in
app/templates/andapp/templates/static/.npm run build
For development, you can use
npm run devto automatically rebuild on file changes. -
Run the Flask Server:
flask run
-
Access the Application:
- Landing Page: http://127.0.0.1:9561/
- Form Page:
http://127.0.0.1:9561/{form-slug}- The
{form-slug}must correspond to the slug of an active and approved form created in the ChapterOS system. - Example with a real form: http://127.0.0.1:9561/acm-25
- The