> ## 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 Flask web server on Discord Bot hosting

What is flask? Flask is a web framework, it’s a Python module that lets you develop web applications easily. It’s has a small and easy-to-extend core. It does have many cool features like url routing, template engine. It is a WSGI web app framework. You can host a flask web server on sparked host! Let's find our how to do so

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

# Installing Flask

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

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

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

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

|| In the example below, we will also be using `python-dotenv`. Make sure to add this to the list of packages if you are using the example below.

3. Restart the service to install the package

# Using Flask

Flask 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 flask web server. 

This is the example code that we have created that you can use. We are also using `python-dotenv` in addition to Flask.

```py
import os
from dotenv import load_dotenv

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "This is a flask web server hosted on Sparked Host!"

if __name__ == "__main__":
    load_dotenv()
    app.run(host='0.0.0.0', port=os.getenv('SERVER_PORT'))
```

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

```
SERVER_PORT=25788
```

|| Note: 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/msedgeveg4ch4xsl_1rd5c4f.png)

---

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

---

Created By: Greg K