https://github.com/banesullivan/server-thread
⚙️ Launch a WSGI or ASGI Application in a background thread with werkzeug or uvicorn
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.3%) to scientific vocabulary
Keywords
Repository
⚙️ Launch a WSGI or ASGI Application in a background thread with werkzeug or uvicorn
Basic Info
Statistics
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 1
- Releases: 1
Topics
Metadata Files
README.md
⚙️ Server Thread
Launch a WSGI or ASGI Application in a background thread with werkzeug or uvicorn.
This application was created for localtileserver
and provides the basis for how it can launch an image tile server as a
background thread for visualizing data in Jupyter notebooks.
While this may not be a widely applicable library, it is useful for a few Python packages I have created that require a background service.
🚀 Usage
Use the ServerThread with any WSGI or ASGI Application.
Start by creating a application (this can be a flask app or a simple app like below):
```py
Create some WSGI Application
from werkzeug import Request, Response
@Request.application def app(request): return Response("howdy", 200) ```
Then launch the app with the ServerThread class:
```py import requests from server_thread import ServerThread
Launch app in a background thread
server = ServerThread(app)
Perform requests against the server without blocking
requests.get(f"http://{server.host}:{server.port}/").raiseforstatus() ```
⬇️ Installation
Get started with server-thread to create applications that require a
WSGIApplication in the background.
🐍 Installing with conda
Conda makes managing server-thread's dependencies across platforms quite
easy and this is the recommended method to install:
bash
conda install -c conda-forge server-thread
🎡 Installing with pip
If you prefer pip, then you can install from PyPI: https://pypi.org/project/server-thread/
pip install server-thread
💭 Feedback
Please share your thoughts and questions on the Discussions board. If you would like to report any bugs or make feature requests, please open an issue.
If filing a bug report, please share a scooby Report:
py
import server_thread
print(server_thread.Report())
🚀 Examples
Minimal examples for using server-thread with common micro-frameworks.
💨 FastAPI
```py import requests from fastapi import FastAPI from server_thread import ServerThread
app = FastAPI()
@app.get("/") def root(): return {"message": "Howdy!"}
server = ServerThread(app) requests.get(f"http://{server.host}:{server.port}/").json() ```
⚗️ Flask
```py import requests from flask import Flask from server_thread import ServerThread
app = Flask("testapp")
@app.route("/") def howdy(): return {"message": "Howdy!"}
server = ServerThread(app) requests.get(f"http://{server.host}:{server.port}/").json() ```
Owner
- Name: Bane Sullivan
- Login: banesullivan
- Kind: user
- Location: United States
- Website: banesullivan.com
- Repositories: 75
- Profile: https://github.com/banesullivan
visualization geek & software engineer. co-created @pyvista.
GitHub Events
Total
- Watch event: 2
- Issue comment event: 3
- Push event: 2
- Pull request event: 2
- Fork event: 1
- Create event: 1
Last Year
- Watch event: 2
- Issue comment event: 3
- Push event: 2
- Pull request event: 2
- Fork event: 1
- Create event: 1
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Bane Sullivan | b****i@g****m | 8 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 2
- Total pull requests: 3
- Average time to close issues: about 7 hours
- Average time to close pull requests: 39 minutes
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 5.0
- Average comments per pull request: 2.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: about 1 hour
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 2.5
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- banesullivan (1)
- wanghaisheng (1)
Pull Request Authors
- vincentsarago (2)
- banesullivan (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 2
-
Total downloads:
- pypi 36,409 last-month
- Total docker downloads: 225
-
Total dependent packages: 3
(may contain duplicates) -
Total dependent repositories: 7
(may contain duplicates) - Total versions: 7
- Total maintainers: 1
pypi.org: server-thread
Launch a WSGI or ASGI Application in a background thread with werkzeug or uvicorn.
- Documentation: https://server-thread.readthedocs.io/
- License: MIT License Copyright (c) 2021-2022 Bane Sullivan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.3.0
published about 1 year ago
Rankings
Maintainers (1)
conda-forge.org: server-thread
Launch a WSGIApplication in a background thread with werkzeug
- Homepage: https://github.com/banesullivan/server-thread
- License: MIT
-
Latest release: 0.2.0
published over 3 years ago
Rankings
Dependencies
- fastapi *
- flask >=2.0.0
- pytest *
- pytest-cov *
- requests *
- scooby *
- uvicorn *
- black *
- codespell *
- flake8 *
- flake8-black *
- flake8-bugbear *
- flake8-isort *
- isort *
- pydocstyle *
- scooby *
- uvicorn *
- werkzeug *
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/upload-artifact v2 composite
- codecov/codecov-action v2 composite