Skip to main content

A simple FastAPI webserver with a bunch of useful resources.

Project description

FastAPI WebServer

This is a wrapper of a FAST API application with some additional features that might be useful for quick web development.

It features:

  • Powerful environment and settings handling with dynamic module import like Django;
  • Local Key-Value Cache database, powered by SQLite;
  • Better logging configuration via commons.logging;
  • Powerful database tools:
    • A Database Adapter to connect to any database on-the-fly;
    • A Data Migration Tool, to run .sql files, or migrate json data that runs automagically on server startup;
    • A FastAPI Dependency for the database (webserver.core.ServerDatabase)
    • A SQLite Cache Database + FastAPI dependency (webserver.core.ServerCache)
  • An SMTP service, implemented on top of fastapi-mail;
  • Internationalization (i18n) on top of Babel:
    • A FastAPI Dependency that discovers the locale based on HTTP Header Accept-Language (webserver.core.AvailableLocale)
  • Front-end tools:
    • SASS Compiler (webserver.frontend.css);
    • Server-Side Rendering via Jinja2Template;
  • Static Files provider;
  • CORS Support;
  • TLS Support + mkcert certificates (local/development only)
  • Content Proxies (webserver.extras.proxies):
    • Gravatar
    • GIPHY

Roadmap

The following features are expected to be implemented in the future. Contribution is welcome.

  • OCI-Compliant Image for Docker/Podman
  • Logging and Tracing API (via OpenTelemetry)
  • Authentication and Authorization
  • Traffic Analyzer
    • (AI) Bot detector
    • VPN detector
    • Rate limiter
    • IP-based Access-Control List (ACL)
  • Content Providers (HTTP client and proxy)
    • Google Fonts API> ⚠️ This is under active development and might not be ready for production environments.

Testing

coverage run -m unittest && coverage html -d tests/coverage/html

Build

uv build && twine upload dist/*

Getting Started

Optionally, set up the environment variables. All environment variables can be found on .env file in the root of this repository.

import webserver
from fastapi import APIRouter, FastAPI

router: APIRouter = APIRouter()
app: FastAPI = webserver.app


@router.get("/")
def index():
  return {"Hello World": f"from {webserver.settings.APP_NAME}"}


app.include_router(router)

if __name__ == "__main__":
  webserver.start()

This enables both local execution through main method as well as fastapi (dev|run) commands.

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

fastapi_webserver-0.4.14.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

fastapi_webserver-0.4.14-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_webserver-0.4.14.tar.gz.

File metadata

  • Download URL: fastapi_webserver-0.4.14.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for fastapi_webserver-0.4.14.tar.gz
Algorithm Hash digest
SHA256 32bc660de8f447f70796ca99afc590ef0fbffdc94e66c6a376431ac98b05142e
MD5 98d472e12099fb9f66c6d20890127e48
BLAKE2b-256 b56839a47c532ac011b0250425973bc5635ef0b8e2f01692aa991e64b72c8e7f

See more details on using hashes here.

File details

Details for the file fastapi_webserver-0.4.14-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_webserver-0.4.14-py3-none-any.whl
Algorithm Hash digest
SHA256 7c3eaeb4f60430bece95410f135234170e03579873e7141bac2324c336de122b
MD5 37916d16ad9a82e94b04a3c92ccf8c8e
BLAKE2b-256 8da1b3d4a31ffe9057871b9979a5285ba85ede9b88baf67a62897ba18ec7f530

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