asphalt-framework / asphalt-web Goto Github PK
View Code? Open in Web Editor NEWWeb application component for the Asphalt framework
License: Apache License 2.0
Web application component for the Asphalt framework
License: Apache License 2.0
Would it make sense to have a configuration parameter that would open a browser window at a given URL based on the host URL, after the server has been launched? Something like:
component:
type: fastapi
components:
myroot:
type: dynamic:WebRootComponent
open_url: my/url
It looks like all the links in the documentation to the examples on GitHub are broken (they point to 1.2.1.post4
which doesn't seem to exist):
https://github.com/asphalt-framework/asphalt-web/tree/1.2.1.post4/examples/asgi3
https://github.com/asphalt-framework/asphalt-web/tree/1.2.1.post4/examples/django
https://github.com/asphalt-framework/asphalt-web/tree/1.2.1.post4/examples/starlette
https://github.com/asphalt-framework/asphalt-web/tree/1.2.1.post4/examples/fastapi
https://github.com/asphalt-framework/asphalt-web/tree/1.2.1.post4/examples/aiohttp
Thankfully, Babel now supports Python 3.4 and 3.5 starting from the recently released version 2.2.
I18n should take hints from request headers. It should also be settable in the session.
Swagger is a really popular tool for API generation: http://swagger.io/
FastAPI recently supported lifespan events, which are passed to the application like this:
from contextlib import asynccontextmanager
from fastapi import FastAPI
def fake_answer_to_everything_ml_model(x: float):
return x * 42
ml_models = {}
@asynccontextmanager
async def lifespan(app: FastAPI):
# Load the ML model
ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model
yield
# Clean up the ML models and release the resources
ml_models.clear()
app = FastAPI(lifespan=lifespan)
@app.get("/predict")
async def predict(x: float):
result = ml_models["answer_to_everything"](x)
return {"result": result}
Does is mean that we cannot let the FastAPI component create the application object (since it's not possible to pass a lifespan), and that we must pass a ready-made application object?
With asphalt-web
, it looks like undefined WebSocket routes return a 403
rather than a 404
:
from asphalt.core import Context
from asphalt.web.fastapi import FastAPIComponent
from fastapi import FastAPI
from websockets import connect
import pytest
@pytest.mark.asyncio
async def test(unused_tcp_port):
application = FastAPI()
async with Context() as ctx:
await FastAPIComponent(
components={},
app=application,
port=unused_tcp_port,
).start(ctx)
async with connect(f"ws://127.0.0.1:{unused_tcp_port}/wrong_ws"):
pass
# websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 403
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.