Static routing
This commit is contained in:
parent
cf2b04a1aa
commit
d7cd92edf7
|
|
@ -1,17 +1,19 @@
|
||||||
import logging.config
|
import logging.config
|
||||||
|
import importlib
|
||||||
from amarillo.app.configuration import configure_services, configure_admin_token
|
import pkgutil
|
||||||
|
|
||||||
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
|
|
||||||
logger = logging.getLogger("main")
|
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from starlette.staticfiles import StaticFiles
|
from starlette.staticfiles import StaticFiles
|
||||||
|
|
||||||
|
import amarillo.plugins
|
||||||
|
from amarillo.app.configuration import configure_services, configure_admin_token
|
||||||
from amarillo.app.routers import carpool, agency, agencyconf, region
|
from amarillo.app.routers import carpool, agency, agencyconf, region
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from amarillo.app.views import home
|
||||||
|
|
||||||
|
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
|
||||||
|
logger = logging.getLogger("main")
|
||||||
|
|
||||||
# https://pydantic-docs.helpmanual.io/usage/settings/
|
# https://pydantic-docs.helpmanual.io/usage/settings/
|
||||||
# from amarillo.app.views import home
|
# from amarillo.app.views import home
|
||||||
|
|
@ -75,13 +77,6 @@ app.include_router(agencyconf.router)
|
||||||
app.include_router(region.router)
|
app.include_router(region.router)
|
||||||
|
|
||||||
|
|
||||||
import importlib
|
|
||||||
import pkgutil
|
|
||||||
|
|
||||||
import amarillo.plugins
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def iter_namespace(ns_pkg):
|
def iter_namespace(ns_pkg):
|
||||||
# Source: https://packaging.python.org/guides/creating-and-discovering-plugins/
|
# Source: https://packaging.python.org/guides/creating-and-discovering-plugins/
|
||||||
return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".")
|
return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".")
|
||||||
|
|
@ -104,15 +99,15 @@ def load_plugins():
|
||||||
def configure():
|
def configure():
|
||||||
configure_admin_token()
|
configure_admin_token()
|
||||||
configure_services()
|
configure_services()
|
||||||
# configure_routing()
|
configure_routing()
|
||||||
load_plugins()
|
load_plugins()
|
||||||
|
|
||||||
|
|
||||||
# def configure_routing():
|
def configure_routing():
|
||||||
# mimetypes.add_type('application/x-protobuf', '.pbf')
|
mimetypes.add_type('application/x-protobuf', '.pbf')
|
||||||
# app.mount('/static', StaticFiles(directory='static'), name='static')
|
app.mount('/static', StaticFiles(directory='static'), name='static')
|
||||||
# app.mount('/gtfs', StaticFiles(directory='data/gtfs'), name='gtfs')
|
app.mount('/gtfs', StaticFiles(directory='data/gtfs'), name='gtfs')
|
||||||
# app.include_router(home.router)
|
app.include_router(home.router)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
17
amarillo/app/views/home.py
Normal file
17
amarillo/app/views/home.py
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import fastapi
|
||||||
|
from starlette.requests import Request
|
||||||
|
from starlette.templating import Jinja2Templates
|
||||||
|
|
||||||
|
templates = Jinja2Templates('templates')
|
||||||
|
|
||||||
|
router = fastapi.APIRouter()
|
||||||
|
|
||||||
|
@router.get('/', include_in_schema=False)
|
||||||
|
async def index(request: Request):
|
||||||
|
|
||||||
|
return templates.TemplateResponse('home/index.html', {"request": request})
|
||||||
|
|
||||||
|
|
||||||
|
@router.get('/favicon.ico', include_in_schema=False)
|
||||||
|
def favicon():
|
||||||
|
return fastapi.responses.RedirectResponse(url='/static/img/favicon.ico')
|
||||||
33
static/css/docs.css
Normal file
33
static/css/docs.css
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
.request {
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||||
|
font-weight: bold;
|
||||||
|
border: 1px solid gray;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.get {
|
||||||
|
color: #2b542c;
|
||||||
|
background-color: #beffbd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post {
|
||||||
|
color: #ae5900;
|
||||||
|
background-color: #ffc79d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.response_formats span {
|
||||||
|
font-weight: bold;
|
||||||
|
color: darkred;
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
font-size: 18px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
186
static/css/theme.css
Normal file
186
static/css/theme.css
Normal file
|
|
@ -0,0 +1,186 @@
|
||||||
|
@import url(//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700);
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
font-weight: 300;
|
||||||
|
color: black;
|
||||||
|
background: white;
|
||||||
|
padding-left: 20px;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,
|
||||||
|
h2,
|
||||||
|
h3,
|
||||||
|
h4,
|
||||||
|
h5,
|
||||||
|
h6 {
|
||||||
|
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.font-normal {
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.font-semi-bold {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.font-bold {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template {
|
||||||
|
margin-top: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content h1 {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content h1 .smaller {
|
||||||
|
font-size: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content .lead {
|
||||||
|
font-size: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links {
|
||||||
|
float: right;
|
||||||
|
right: 0;
|
||||||
|
margin-top: 125px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul {
|
||||||
|
display: block;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li {
|
||||||
|
list-style: none;
|
||||||
|
display: inline;
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li:first-child {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li:last-child {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li.current-version {
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li a, a {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li a:hover, a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li .icon-muted {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .copyright {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 0.9em;
|
||||||
|
text-transform: lowercase;
|
||||||
|
float: right;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1199px) {
|
||||||
|
.starter-template .content h1 {
|
||||||
|
font-size: 45px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content h1 .smaller {
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content .lead {
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 991px) {
|
||||||
|
.starter-template {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .logo {
|
||||||
|
margin: 40px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content {
|
||||||
|
margin-left: 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content h1 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links {
|
||||||
|
float: none;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 60px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .copyright {
|
||||||
|
float: none;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.starter-template .content h1 .smaller {
|
||||||
|
font-size: 25px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .content .lead {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .links ul li .icon-muted {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.starter-template .copyright {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.disclaimer {
|
||||||
|
margin-top: 20px;
|
||||||
|
font-style: italic;
|
||||||
|
|
||||||
|
}
|
||||||
BIN
static/img/cloud.png
Normal file
BIN
static/img/cloud.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
static/img/favicon.ico
Normal file
BIN
static/img/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
34
templates/home/index.html
Normal file
34
templates/home/index.html
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
{% extends "shared/layout.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
Amarillo - Der Carpooling-Intermediär
|
||||||
|
</h1>
|
||||||
|
<h2>Hintergrund</h2>
|
||||||
|
<p>
|
||||||
|
Ein "Amarillo" ist ein <a href="https://www.cubatravelnetwork.com/de/autoverleih-in-kuba/autofahren-auf-kuba">gelb gekleideter Verkehrsregler</a>, der auf Kuba Trampern eine möglichst passsende Mitfahrgelegenheit vermittelt.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Ebenso wie ein kubanischer Amarillo hilft auch dieser Amarillo-Dienst, passende Mitfahrgelegenheiten zu vermitteln. Mitfahrplattformen können Mitfahrangebote ihrer
|
||||||
|
Nutzerinnen über die Amarillo-REST-API publizieren und so Reiseplanern oder Meta-Suchmaschinen zur Verfügung stellen.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Amarillo reichert diese Mitfahrangebote um die mutmaßliche Fahrtroute sowie entlang
|
||||||
|
dieser liegenden Zustiegs- und Ausstiegspunkte an, so dass Reiseplaner für Mitfahrene gut erreichbare Treffpunkte vorschlagen können, die mit geringen Umwegen angefahren werden können, wie z.B. Parken-und-Mitfahren-Parkplätze, Bahnhöfe oder Bushaltestellen.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Für die einfache Integration in Reiseplaner stellt Amarillo die Mitfahrangebote aller
|
||||||
|
publizierenen Mitfahrbörsen nächtlich als regionale GTFS-Feeds bzw. minütlich als GTFS-RT Feeds bereit. Der GTFS-RT-Feed enthält alle seit dem Vortag um Mitternacht hinzugefügten, aktualisierten oder gelöschten Mitfahrangebote als ADDED bzw. CANCELED TripUpdates. Die amarillo-spezifischen Erweiterungen werden in dieser <a href="https://github.com/mfdz/amarillo/blob/main/app/proto/realtime_extension.proto">Prototype-Extension</a> definiert.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Die DigitalAgentur Brandenburg GmbH als Betreiber dieses Amarillo-Dienstes für die kommunale Mobilitätsplattform <a href="https://bbnavi.de">bbnavi.de</a> und das Mitfahrangebot <a href="https://mitfahrenbb.de">mitfahrenbb.de</a> ist offen für die Aufnahme weiterer Mitfahrplattformen – sowohl für die Integration von Mitfahrangeboten über Amarillo als auch für das Aufgeben von Angeboten über unsere Seiten. Möchte die Mitfahrplatfform minutenaktuelle Mitfahrangebote bereitstellen, sollte sie die carpool-POST/PUT/DELETE-Endpunkte für jede Aktualisierung eines Inserats aufrufen. Bei Interesse an einer Integration bzw. um den hierfür notwendigen API-Key zu erhalten, nehmen Sie gerne über Kontakt bbnavi at digital-agentur punkt de mit uns auf.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3>Dokumentation</h3>
|
||||||
|
<p>
|
||||||
|
Die Dokumentation dieses Dienstes ist als <a href="/docs">OpenAPI-Dokumentation</a> verfügbar.
|
||||||
|
Der Quellcode ist unter AGPL-Lizenz in diesem <a href="https://github.com/mfdz/amarillo">Github-Repository</a> einseh- und abrufbar.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
96
templates/shared/layout.html
Normal file
96
templates/shared/layout.html
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Amarillo</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
margin: 1rem;
|
||||||
|
font-size: 100%;
|
||||||
|
font-family: sans-serif;
|
||||||
|
line-height: 1.35;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
margin-top: 5rem;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover, a:focus, a:active {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
a, a:visited {
|
||||||
|
color: #da1b1b;
|
||||||
|
}
|
||||||
|
h1, h2, h3 {
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: .8em;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
padding-bottom: 1em;
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
#bbnavi-logo {
|
||||||
|
display: inline-block;
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
#bbnavi-logo svg {
|
||||||
|
display: inline-block;
|
||||||
|
width: 3rem;
|
||||||
|
vertical-align: bottom;
|
||||||
|
}
|
||||||
|
#barshare-logo {
|
||||||
|
max-height: 3rem;
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
position: relative;
|
||||||
|
top: -.3rem;
|
||||||
|
}
|
||||||
|
footer {
|
||||||
|
padding-top: 1em;
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
footer > :first-child {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
footer ul {
|
||||||
|
list-style: none;
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<a id="bbnavi-logo" href="https://bbnavi.de/">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 75 75">
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.cls-1{fill: #da1b1b;}.cls-2{fill: #fff;}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<rect class="cls-1" x="5" y="5" width="65" height="65" rx="10"/>
|
||||||
|
<path class="cls-2" d="M41,48.91l7.17-20.44,1.05-3a12.77,12.77,0,0,0,.25-2.5,12.15,12.15,0,1,0-24.29,0,12.35,12.35,0,0,0,.32,2.81l.84,2.38,7.28,20.75C19,49.42,7.81,52.62,7.81,56.51c0,4.22,13.29,7.65,29.69,7.65s29.69-3.43,29.69-7.65C67.19,52.58,55.72,49.35,41,48.91ZM37.05,61c-12.92,0-23.39-2.12-23.39-4.73,0-2.44,9.12-4.44,20.84-4.7L36.41,57a.9.9,0,0,0,1.69,0L40,51.59c11.53.3,20.44,2.28,20.44,4.69C60.44,58.89,50,61,37.05,61Z"/>
|
||||||
|
</svg>
|
||||||
|
Amarillo
|
||||||
|
</a>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="content">
|
||||||
|
THIS PAGE HAS NO CONTENT
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://bbnavi.de/impressum/">Impressum</a></li>
|
||||||
|
<li><a href="https://bbnavi.de/datenschutzerklaerung/">Datenschutz</a></li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in a new issue