> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.sparkedhost.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to host a Express web server on Discord Bot hosting

What is express? Well, Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Let's find out how to host a Express web server on Discord Bot hosting!

| There is a video version of this article available. Click [here](https://www.youtube.com/watch?v=jWZ1KZYHuyY&ab_channel=SparkedHost) to view the video.

# Installing Express

1. Head over to your service and click "Startup".

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/startup_xxfs1m.png)

2. Under the "Node Packages" box, add `express` to the list of packages. Just like so:

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/screenshot-2023-01-22-233359_110q3er.png)

3. Restart the service to install the package

# Using Express

Express is easy to use and a lot of documentation is available for you to learn the ins and outs of the package. However, we will teach you how to setup a basic express web server.

```js
const express = require('express')
const app = express()

//This is a GET request route. It will be called when the user visits the root of the site.
app.get('/', (req, res) => {
  res.send('Hello World! This is a GET request.')
})

//This is a POST request route. It will be called when the user submits data on the site.
app.post('/', (req, res) => {
    res.send('Got a POST request')
})

//This sets the port that the web server will listen on. It will be the port specified in the .env file. 
app.listen(process.env.SERVER_PORT, () => {
  console.log(`Example app listening on port ${process.env.SERVER_PORT}`)
})```

Then create a file called `.env`. The contents of the file should like this:

```
SERVER_PORT=25788
```

|| Make sure to change the port to the port that is assigned as "Primary" on your service.

If you access the URL, the result should look something like this

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/screenshot-2023-01-23-000136_1905ee6.png)

---

If you require any further assistance, please create a ticket [here](https://billing.sparkedhost.com/submitticket.php).

---

Created By: Greg K