Setting Up a Python (Flask) Application (Firstserv Guide)

This guide walks you through creating a basic Python application using Flask on your Firstserv hosting account.


Important Notes

  • Firstserv supports the Python environment and service only
  • Troubleshooting your application, dependencies, or code is outside our support scope
  • For production-grade Python applications, we recommend using a VPS or dedicated server

Step 1: Create a Python Application

  1. Log in to your cPanel account
  2. Navigate to the Software section
  3. Click Setup Python App

Create the Application

  1. Click + Create Application

  2. Complete the required fields, for example:

    • Application Root: /home/youraccount/myapp
    • Application URL: https://yourdomain.com/python-demo
    • Python Version: Select an available version
  3. Click Create


Step 2: Access Your Virtual Environment

Once the application is created, cPanel will display a command to activate your Python environment.

  1. Connect via:

    • cPanel → Terminal, or
    • SSH (external client)
  2. Run the activation command shown (example):

 
 
 
 
 
 
Shell
 
 
source /home/youraccount/virtualenv/myapp/3.7/bin/activate && cd /home/youraccount/myapp
 
 

✅ Your command prompt will update (e.g. (myapp:3.7)), confirming the environment is active.


Step 3: Check Application Files

List the files in your application directory:

 
 
 
 
 
 
Shell
 
 
ls -la
 
 

You should see files similar to:

  • start.py (startup file)
  • passenger_wsgi.py (used by the server)
  • public/ directory

✅ At this stage, visiting your app URL may show a simple test page.


Step 4: Install Flask

Install Flask within your environment:

 
 
 
 
 
 
Shell
 
 
pip install flask
 
 

Step 5: Create a Basic Flask App

Edit the start.py file using your preferred editor (e.g. nano):

 
 
 
 
 
 
Shell
 
 
nano start.py
 
 

Replace its contents with:

 
 
 
 
 
 
Python
 
 
from flask import Flask
app = Flask(__name__)
 
@app.route("/")
def hello():
return "Welcome to your Flask application!\n"
 
if __name__ == "__main__":
app.run()
 
 

Save the file (Ctrl + X, then confirm).


Step 6: Test the Application (Optional)

Run the built-in Flask server:

 
 
 
 
 
 
Shell
 
 
python start.py
 
 

You should see output similar to:

Running on http://127.0.0.1:5000/

⚠️ This is a development server only. Press Ctrl + C to stop it.


Step 7: Access Your Application via Browser

Now visit your application URL:

https://yourdomain.com/python-demo

✅ You should see:

Welcome to your Flask application!

Your app is now being served via Passenger (the web server integration).


How It Works

  • Passenger connects your Python app to the web server
  • passenger_wsgi.py acts as the bridge between your app and the server
  • start.py defines your application logic

Best Practices

  • Keep dependencies within your virtual environment
  • Test changes before deploying to live
  • Maintain backups before major updates
  • Monitor logs for errors during development

Summary

To set up a Python app on Firstserv:

  1. Create an app via cPanel
  2. Activate the virtual environment
  3. Install dependencies (e.g. Flask)
  4. Configure your application files
  5. Access your app via browser

If you need help confirming your Python environment is running correctly, the Firstserv support team is happy to assist.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Python apps

Testing Python Functionality with a “Hello World” App (Firstserv Guide)...