zliang commited on
Commit
58ce433
1 Parent(s): e585fe2

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +21 -2
main.py CHANGED
@@ -2,15 +2,34 @@ from fastapi import FastAPI, HTTPException
2
  import urllib.request
3
  from urllib.error import HTTPError
4
  from habanero import Crossref
 
5
 
6
 
7
  app = FastAPI()
8
 
9
  BASE_URL = 'https://doi.org/'
10
 
11
- @app.get("/")
12
  def read_root():
13
- return {"Hello": "Welcome to doi2ref, a GPTs who can turn doi into various reference formats"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  @app.get("/title2ref/")
16
  async def title2doi(title:str):
 
2
  import urllib.request
3
  from urllib.error import HTTPError
4
  from habanero import Crossref
5
+ from fastapi.responses import HTMLResponse
6
 
7
 
8
  app = FastAPI()
9
 
10
  BASE_URL = 'https://doi.org/'
11
 
12
+ @app.get("/", response_class=HTMLResponse)
13
  def read_root():
14
+ html_content = """
15
+ <html>
16
+ <head>
17
+ <title>Citation Helper</title>
18
+ </head>
19
+ <body>
20
+ <h1>Hello!</h1>
21
+ <p>As Citation Helper, I specialize in generating citations for academic papers. You can provide me with the DOI (Digital Object Identifier) or the title of an academic paper, and I will create a citation for it.</p>
22
+ <p>Here's how you can use my service:</p>
23
+ <ul>
24
+ <li><b>Provide a DOI or Title:</b> Share the DOI or the title of the paper you need a citation for.</li>
25
+ <li><b>Choose a Citation Style:</b> After I generate the citation in APA format, you can request it in another style like Chicago, MLA, or Harvard if needed.</li>
26
+ <li><b>Receive Your Citation:</b> I'll provide you with the correctly formatted citation.</li>
27
+ </ul>
28
+ <p>Feel free to start by giving me a DOI or a paper title!</p>
29
+ </body>
30
+ </html>
31
+ """
32
+ return HTMLResponse(content=html_content)
33
 
34
  @app.get("/title2ref/")
35
  async def title2doi(title:str):