If you're a newcomer to Gradio, we recommend getting familiar with the overall structure of the repository so that you can focus on the part of the source code you'd like to contribute to.
-`/gradio`: contains the Python source code for the library
-`/gradio/interface.py`: contains the Python source code for the core `Interface` class
-`/gradio/blocks.py`: contains the Python source code for the core `Blocks` class
-`/gradio/components/`: the directory that contains the Python source code for all of the Gradio components.
-`/js`: contains the HTML/JS/CSS source code for the library ([start here for frontend changes](/js/README.md))
This will start the backend server in reload mode, which will watch for changes in the `gradio` folder and reload the app if changes are made. By default, Gradio will launch on port 7860. You can also just use `python app.py`, but this won't automatically trigger updates.
If you're making frontend changes, start the frontend server:
```
pnpm dev
```
This will open a separate browser tab. By default, Gradio will launch this on port 9876. Any changes to the frontend will also reload automatically in the browser. For more information about developing in the frontend, you can refer to [js/README.md](js/README.md).
We also have demos of all our components in the `/gradio/demo` directory. To get our simple gradio Chatbot running locally:
```
gradio demo/chatbot_simple/run.py
```
## 🧪 Testing
We use Pytest, Playwright and Vitest to test our code.
- The Python tests are located in `/test`. To run these tests:
- Browser tests are located in `js/app/test` and are defined as `*spec.ts` files. To run browser tests:
```
pnpm test:browser
```
To build the frontend code before running browser tests:
```
pnpm test:browser:full
```
You can also run browser tests in the UI mode by adding the `--ui` flag:
```
pnpm test:browser --ui
```
If you have made any significant visual changes to a component, we encourage you to add a new Storybook story or amend an existing one to reflect them. You can create a new story with a `*.stories.svelte` file.
## 🕸️ Gradio Website
We also welcome any contributions to our [website](https://www.gradio.app).
First, build the website:
```
pnpm build:cdn-local
```
then serve the website build:
```
pnpm preview:cdn-local
```
This will serve a build of `gradio.js` on port `4321`. You can then navigate to `js/_website/src/routes/+layout.svelte` and replace the source of the website build from:
All PRs should be against `main`, and ideally should address an open issue, unless the change is small. Direct commits to main are blocked, and PRs require an approving review to merge into main. By convention, the Gradio maintainers will review PRs when:
- A clear, descriptive title has been assigned to the PR
- A maintainer (@abidlabs, @aliabid94, @aliabd, @AK391, @dawoodkhan82, @pngwn, @freddyaboulton, @hannahblair) is tagged in the PR comments and asked to complete a review
🧹 We ask that you make sure initial CI checks are passing before requesting a review. One of the Gradio maintainers will merge the PR when all the checks are passing. You can safely ignore the Vercel and Spaces checks, which only run under maintainers' pull requests.
Thank you for taking the time to contribute to our project!
## ❓ Need help getting started?
- Browse [issues](https://github.com/gradio-app/gradio/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) with the "good first issue" label. These are issues we think are good for newcomers.
- Ask the Gradio community in our [Discord](https://discord.com/invite/feTf9x3ZSB)
- Raise an issue for a feature or a bug you want to tackle
## 🚧 Troubleshooting
`ERROR: Error loading ASGI app. Could not import module "<filename>"`
Verify that you've used the correct filename of your gradio app, and that you're in the directory of the file.