Skip to content

Commit c4709e2

Browse files
Serving static html files
1 parent 602db34 commit c4709e2

5 files changed

Lines changed: 43 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ Create docker image
9494

9595
Run the created docker image
9696

97-
docker run -it --rm --network=python-fastapi-network -e 'APP_DB_HOST=python-fastapi-postgres' -e 'PORT=8000' -p 8000:8000 python-fastapi
97+
docker run -it --rm --network=python-fastapi-network -e 'APP_DB_HOST=python-fastapi-postgres' -e 'APP_EXTERNAL_FAQ_API_BASE_URL=http://prism-mock-open-api:4010' -e 'PORT=8000' -p 8000:8000 python-fastapi
9898

9999
http://localhost:8000

app/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import structlog
22
import uvicorn
33
from fastapi import FastAPI
4+
from fastapi.staticfiles import StaticFiles
45
from starlette.middleware.base import BaseHTTPMiddleware
56
from contextlib import asynccontextmanager
67
from fastapi.exception_handlers import (
@@ -36,6 +37,7 @@
3637
context.include_router(customer_router)
3738
context.include_router(dependency_router)
3839
context.include_router(external_faq_router)
40+
context.mount("/static", StaticFiles(directory="app/static"), name="static")
3941

4042

4143
@asynccontextmanager

app/static/sample_form.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Sample Form</title>
5+
</head>
6+
<body>
7+
8+
<h1>Sample Form with multiple files upload</h1>
9+
<form action="/form-submit" method="post" enctype="multipart/form-data">
10+
<label for="fname">First name:</label><br>
11+
<input type="text" id="fname" name="firstName"><br>
12+
<label for="lname">Last name:</label><br>
13+
<input type="text" id="lname" name="lastName">
14+
<br/>
15+
<label for="myfile">Select a file(s):</label>
16+
<input type="file" id="myfile" name="files" multiple>
17+
<br/>
18+
<input type="submit" value="Submit">
19+
</form>
20+
</body>
21+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>Success Form Submit</title>
5+
</head>
6+
<body>
7+
8+
<h1>Success Form Submit</h1>
9+
10+
<form action="/sample_form.html" method="get">
11+
<input type="submit" value="Submit another form">
12+
</form>
13+
</body>
14+
</html>

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ services:
2222
- "4010:4010"
2323
volumes:
2424
- ./sample-openapi-spec.json:/tmp/sample-openapi-spec.json
25-
command: mock -h 0.0.0.0 /tmp/sample-openapi-spec.json
25+
command: mock -h 0.0.0.0 /tmp/sample-openapi-spec.json
26+
networks:
27+
main:
28+
aliases:
29+
- prism-mock-open-api

0 commit comments

Comments
 (0)