Skip to content
hackerlemonaruPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

FastAPI Server

A lightweight, production-ready FastAPI server that you can clone, configure with your own IP & port, and expose to the internet.


Features

  • FastAPI with auto-generated docs (/docs, /redoc)
  • Configurable host IP and port via .env file
  • Works on Linux, macOS, Windows
  • One-command startup scripts
  • Health check endpoint at /health

Quick Start

1. Clone the repo

git clone https://github.com/hackerlemonaru/FastAPI.git
cd FastAPI

2. Install dependencies

pip install -r requirements.txt

3. Configure your IP and Port

cp .env.example .env

Edit .env to set your IP and port:

HOST=0.0.0.0   # 0.0.0.0 = accept from all interfaces (recommended)
PORT=8000      # change this to any open port you want
WORKERS=1
LOG_LEVEL=info

Tip: Use HOST=0.0.0.0 so the server accepts connections from any IP.
Then use your machine's public IP to access it from the internet.

4. Start the server

Linux / macOS:

chmod +x start.sh
./start.sh

Windows:

start.bat

Or manually:

hypercorn main:app --bind 0.0.0.0:8000 --reload

API Endpoints

Method Path Description
GET / Hello World response
GET /health Health check
GET /info Server info (host/port)
GET /docs Swagger UI
GET /redoc ReDoc documentation

Access from the Internet

To make your server accessible from the internet:

On Linux/Ubuntu Server

  1. Open the port in firewall:

    sudo ufw allow 8000/tcp
    sudo ufw reload
  2. Find your public IP:

    curl ifconfig.me
  3. Access via browser or curl:

    http://YOUR_PUBLIC_IP:8000
    http://YOUR_PUBLIC_IP:8000/docs
    

On a Home PC (behind router)

  1. Set up Port Forwarding in your router settings:

    • External Port: 8000
    • Internal IP: your local machine IP (e.g. 192.168.1.x)
    • Internal Port: 8000
    • Protocol: TCP
  2. Find your public IP at https://whatismyip.com

  3. Access: http://YOUR_PUBLIC_IP:8000

Using a Cloud Server (VPS)

Works out of the box — just open the port in your cloud provider's security group / firewall rules and run the server with HOST=0.0.0.0.


Project Structure

FastAPI/
├── main.py            # FastAPI application
├── requirements.txt   # Python dependencies
├── .env.example       # Config template (copy to .env)
├── .env               # Your config (NOT committed to git)
├── start.sh           # Linux/macOS startup script
├── start.bat          # Windows startup script
├── railway.json       # Railway.app deployment config
└── README.md          # This file

Deploy to Railway (Cloud)

Deploy on Railway

Railway will automatically set PORT via environment variable — no manual config needed.


Tech Stack

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages