Skip to main content

Run your Python bot alongside a lightweight Flask web server.

Project description

StayPresent

A lightweight Python package that keeps your bot or script alive by running a small Flask web server alongside your application.

Perfect for platforms like Render, Railway, Koyeb, Heroku, or anywhere an HTTP server is required to keep your service active.


Features

  • 🚀 One-line setup
  • 🌐 Built-in Flask web server
  • 🤖 Runs your Python bot/script automatically
  • 📄 Custom text response
  • 📦 JSON response support
  • ⚡ Lightweight and easy to use

Installation

pip install staypresent

Or install locally:

pip install .

Basic Usage

import staypresent

staypresent.web.text("Made With ❤️")

staypresent.run("bot.py")

Open your browser:

http://localhost:8080

Response:

Made With ❤️

JSON Response

import staypresent

staypresent.web.json({
    "status": "online",
    "developer": "John",
    "message": "Made With Love ❤️"
})

staypresent.run("bot.py")

Response

{
  "status": "online",
  "developer": "John",
  "message": "Made With Love ❤️"
}

Custom Port

import staypresent

staypresent.run(
    "bot.py",
    port=5000
)

Custom Host

staypresent.run(
    "bot.py",
    host="0.0.0.0"
)

Complete Example

import staypresent

staypresent.web.json({
    "status": "Running",
    "version": "1.0.0",
    "message": "Made With Love ❤️"
})

staypresent.run(
    "body.py",
    host="0.0.0.0",
    port=8080
)

API

Run your bot

staypresent.run(
    bot_file,
    host="0.0.0.0",
    port=8080
)
Parameter Type Description
bot_file str Path to your Python script
host str Flask host
port int Flask port

Plain Text Response

staypresent.web.text("Hello World")

JSON Response

staypresent.web.json({
    "hello": "world"
})

Health Check

A /health endpoint is always available alongside your custom / response, returning {"status": "ok"}. Useful for platforms that want a dedicated health-check path separate from your custom response.


Requirements

  • Python 3.8+
  • Flask

Use Cases

  • Telegram Bots
  • Discord Bots
  • Automation Scripts
  • Background Workers
  • Render Deployments
  • Railway Deployments
  • Koyeb Deployments
  • Heroku Apps

License

MIT License


Made with ❤️ using Python.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

staypresent-1.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

staypresent-1.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file staypresent-1.0.1.tar.gz.

File metadata

  • Download URL: staypresent-1.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for staypresent-1.0.1.tar.gz
Algorithm Hash digest
SHA256 af91ec3a6f0938f8a065379d462554e7e3e644220c368a67442cef614f0b9bba
MD5 eb0971d05981d964bd49334c2e290acf
BLAKE2b-256 21d9dc30acb4b9b68b659d7d34e600e880e2633166dfb246e85c07971e0c726f

See more details on using hashes here.

File details

Details for the file staypresent-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: staypresent-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for staypresent-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12890c22423811a2fad4be9ae345bb2b343f515384d34755497ce506a65cfd41
MD5 192e3ebb9c9334286228fcb0115b8a7f
BLAKE2b-256 9a37bda96b714347c832774a32da7507a15e6b654f2418ec848ec378c5f69ff2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page