This application is a Fast Api server with the ability to provide the exchange rate of coins on any date. The main idea:
- FAST API Server.
- use API of https://cbr.ru/development/SXML/ to get new information about exchange rate of coins.
- Check information in database - Mongo DB.
- Save new information on Mongo Db database.
you can make a request http://127.0.0.1:8000/coin/GBP where GBP - is a coin of England
- Vue JS.
- the user can write the name of coin and get information from our Fast Api Server.
- Ready Dockerfile and Docker-compose.yml to RUN Containers.
Just type the command: docker-compose up Container for app + Container for MongoDB
Interesting points about API of SBR:
- All information from https://cbr.ru/development/SXML/ we recive not in JSON but as XML so we need to use - import xmltodict as xmltodict
Intresting points about Mongo db to JSON:
- When we try to pass Mongo Db information as JSON response in Fast API we can recieve problem with '_ id' because it is not just field like int or str, so Fast Api can't serialize this field, the opcion is not use this field, just skip it like:
find_item = collection_name.find_one({'date': f'{date}'}, {'_id': 0}).
RESOLVED Problem.
When we try make a API request from Vue JS to localhost Fast Api you can get this error:
- fast api from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
You can do:
from fastapi.middleware.cors import CORSMiddleware
and add:
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=[""],
allow_headers=[""],
)
-
➡️ Check out my website. You can find a detailed description of the projects
-
➡️ Сommercial project. Flask project. Foreign language teacher website. - See on-line website.
-
➡️ Сommercial project. Django project. Online School with personal classrooms of students and teachers. - See online website.
-
➡️ Сommercial project. Django project. For goverment school № 205. - See on-line website.
-
➡️ Django project Mobile shop, education purpose. Working on it