StayPresent β€” Keep Your Python Bots Alive Without the Boilerplate πŸš€

μž‘μ„±μž

μΉ΄ν…Œκ³ λ¦¬:

← ν”Όλ“œλ‘œ
DEV Community · John Wick · 2026-07-30 개발(SW)

John Wick

StayPresent β€” Keep Your Python Bots Alive Without the Boilerplate πŸš€

If you’ve ever deployed a Discord bot, Telegram bot, or any long-running Python script to a platform like Render, Railway, Koyeb, or Heroku, you’ve probably run into the same problem.

Your application needs an active HTTP service, but your project isn’t a web application.

Most people end up writing a tiny Flask server just to satisfy the hosting platform’s health checks. It works… but it also means copying the same boilerplate into every project.

I got tired of doing that.

So I built StayPresent.

What is StayPresent?

StayPresent is a lightweight Python package that lets you run a web server alongside your bot or background script with almost no setup.

Instead of writing and maintaining a Flask server yourself, you simply do:

import staypresent

staypresent.run("bot.py")

Enter fullscreen mode Exit fullscreen mode

That’s it.

StayPresent starts an HTTP server in the background while your bot runs normally. If your bot crashes, it automatically restarts it.

Why I Built It

Almost every bot deployment tutorial includes something like this:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def home():
    return "Bot is running"

app.run(host="0.0.0.0", port=8080)

Enter fullscreen mode Exit fullscreen mode

The code itself isn’t difficult.

The problem is having to copy it into every single project.

I wanted something that worked like this instead:

  • Install one package
  • Import it
  • Run your bot
  • Forget about the web server forever

That idea eventually became StayPresent.

Features

✨ One-line setup

staypresent.run("bot.py")

Enter fullscreen mode Exit fullscreen mode

πŸš€ Automatic crash recovery

If your bot exits unexpectedly, StayPresent can automatically restart it.

πŸ€– Multiple bot support

staypresent.run([
    "telegram_bot.py",
    "discord_bot.py",
])

Enter fullscreen mode Exit fullscreen mode

Each process is monitored independently.

🌐 Built-in web responses

Serve:

  • Plain text
  • JSON
  • HTML
  • Markdown

Example:

staypresent.web.markdown("CHANGELOG.md")

Enter fullscreen mode Exit fullscreen mode

Now your changelog becomes a nice-looking web page.

🎨 Built-in Markdown renderer

No extra Markdown package required.

It supports:

  • Tables
  • Images
  • Code blocks
  • Nested lists
  • GitHub-like styling
  • Light & Dark themes

βš™ Production ready

If waitress is installed, StayPresent automatically uses it instead of Flask’s development server.

Example

import staypresent

staypresent.web.markdown("README.md")

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

Enter fullscreen mode Exit fullscreen mode

A web server starts, your bot launches, and everything runs together.

Optional Keep-Warm

Some free hosting platforms suspend inactive services.

StayPresent also includes an optional self-ping utility.

import staypresent

staypresent.cron(
    "https://my-app.onrender.com",
    interval=300
)

Enter fullscreen mode Exit fullscreen mode

Enable it only if you actually need it.

Installation

pip install staypresent

Enter fullscreen mode Exit fullscreen mode

Production installation:

pip install staypresent[prod]

Enter fullscreen mode Exit fullscreen mode

Open Source

StayPresent is completely open source.

GitHub:
https://github.com/StayElite/StayPresent

PyPI:
https://pypi.org/project/staypresent/

I’d love feedback, bug reports, feature requests, or even just ideas for improving it.

If you find it useful, consider giving the repository a ⭐.

Happy coding! πŸš€

μ›λ¬Έμ—μ„œ 계속 β†—

μ½”λ©˜νŠΈ

λ‹΅κΈ€ 남기기

이메일 μ£Όμ†ŒλŠ” κ³΅κ°œλ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. ν•„μˆ˜ ν•„λ“œλŠ” *둜 ν‘œμ‹œλ©λ‹ˆλ‹€