AhmedSaghir
commited on
Commit
•
ec23308
1
Parent(s):
89f14b7
Upload 3 files
Browse files- Dockerfile +9 -0
- main.py +51 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY . /app
|
6 |
+
|
7 |
+
RUN pip install -r requirements.txt
|
8 |
+
|
9 |
+
CMD uvicorn main:app --reload --port=8000 --host=0.0.0.0
|
main.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Code
|
2 |
+
from fastapi import FastAPI
|
3 |
+
import nest_asyncio
|
4 |
+
#from pyngrok import ngrok
|
5 |
+
import uvicorn
|
6 |
+
|
7 |
+
|
8 |
+
#from transformers import pipeline
|
9 |
+
|
10 |
+
#model_path = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
11 |
+
#sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
12 |
+
|
13 |
+
|
14 |
+
app = FastAPI()
|
15 |
+
|
16 |
+
@app.get("/")
|
17 |
+
async def root():
|
18 |
+
return {"message": "Hello World"}
|
19 |
+
|
20 |
+
@app.get('/enwi')
|
21 |
+
async def abc():
|
22 |
+
st = ''
|
23 |
+
for i in range(10):
|
24 |
+
st += str(i * 2) + " "
|
25 |
+
|
26 |
+
return st
|
27 |
+
|
28 |
+
|
29 |
+
#@app.get('/sentiment/{intput_text}')
|
30 |
+
#async def mlmodel(intput_text):
|
31 |
+
#
|
32 |
+
# result = sentiment_task(intput_text)
|
33 |
+
|
34 |
+
# return result
|
35 |
+
|
36 |
+
@app.get('/a/{name}/{password}')
|
37 |
+
async def abc(name, password):
|
38 |
+
|
39 |
+
if int(password) == 123 and name == "abc":
|
40 |
+
return "Correct password"
|
41 |
+
else:
|
42 |
+
return "Incorrect Password"
|
43 |
+
|
44 |
+
@app.get('/')
|
45 |
+
async def home():
|
46 |
+
return "Hello Atom Camp"
|
47 |
+
|
48 |
+
#ngrok_tunnel = ngrok.connect(8000)
|
49 |
+
#print('Public URL:', ngrok_tunnel.public_url)
|
50 |
+
nest_asyncio.apply()
|
51 |
+
#uvicorn.run(app, port=8000)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
nest-asyncio
|
3 |
+
pyngrok
|
4 |
+
uvicorn
|