Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text decipher and Schulte exercises #3

Merged
merged 7 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
build-and-push:
name: Deploy images on the destination server
name: Build and test run compose configuration
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand Down
80 changes: 55 additions & 25 deletions app/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
server {
server_tokens off;
server
{
server_tokens off;

listen 80;
gzip on;
gzip_static on;
gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss font/eot font/otf font/ttf font/woff2;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_min_length 256;
listen 80;
gzip on;
gzip_static on;
gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss font/eot font/otf font/ttf font/woff2;
gzip_proxied any;
gzip_vary on;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_min_length 256;

server_name ${HOSTNAME};
server_name ${HOSTNAME};

location /api/ {
proxy_pass http://backend:8000;
}
location / {
expires max;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://frontend:4000;
}
include /etc/nginx/mime.types;

location /api/
{
proxy_pass http://backend:8000;
}
location ~* \.html$
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
expires -1;
add_header Cache-Control "no-cache, no-store, must-revalidate";

proxy_pass http://frontend:4000;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
expires max;
add_header Cache-Control "public";
proxy_pass http://frontend:4000;
}

location /
{
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://frontend:4000;
}
}
14 changes: 9 additions & 5 deletions backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class TextModel(BaseModel):
text: str


class TextResponse(BaseModel):
id: int
word: str
tag: Optional[str]
normal_form: Optional[str]


api = FastAPI()
app = FastAPI()

Expand All @@ -36,12 +43,11 @@ class TextModel(BaseModel):
allow_methods=["*"],
allow_headers=["*"],
)
analized = str


@api.post('/parse/')
async def create_text(text: TextModel, colors: Optional[dict] = None):
analized = await analize_text(text.text, colors)
analized = await analize_text(text.text)
return analized


Expand All @@ -54,12 +60,10 @@ async def count_text(text: TextModel):
return JSONResponse(res)


@api.get('/parse')
async def get_text():
return analized

app.mount('/api', api)


@app.on_event('startup')
async def init_cache():
redis = from_url(f'redis://{REDIS_URL}', encoding="utf8", decode_responses=True)
Expand Down
Loading
Loading