edithram23 commited on
Commit
a5deb9e
·
verified ·
1 Parent(s): 52db929

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +32 -3
main.py CHANGED
@@ -25,10 +25,39 @@ from fastapi import FastAPI
25
  import uvicorn
26
 
27
  app = FastAPI()
 
 
28
 
29
- @app.get("/")
30
- async def hello():
31
- return {"msg" : "Live"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  @app.post("/mask")
34
  async def mask_input(query):
 
25
  import uvicorn
26
 
27
  app = FastAPI()
28
+ from fastapi import FastAPI, Form
29
+ from fastapi.responses import HTMLResponse
30
 
31
+ app = FastAPI()
32
+
33
+ # Serve the HTML form
34
+ @app.get("/", response_class=HTMLResponse)
35
+ async def read_form():
36
+ html_content = """
37
+ <!DOCTYPE html>
38
+ <html>
39
+ <head>
40
+ <title>FastAPI Input Form</title>
41
+ </head>
42
+ <body>
43
+ <h1>Enter Your Message</h1>
44
+ <form action="/submit" method="post">
45
+ <label for="message">Message:</label>
46
+ <input type="text" id="message" name="message">
47
+ <input type="submit" value="Submit">
48
+ </form>
49
+ </body>
50
+ </html>
51
+ """
52
+ return html_content
53
+
54
+ # Handle the form submission
55
+ @app.post("/submit")
56
+ async def submit_form(message: str = Form(...)):
57
+ return {"message": message}
58
+ # @app.get("/")
59
+ # async def hello():
60
+ # return {"msg" : "Live"}
61
 
62
  @app.post("/mask")
63
  async def mask_input(query):