Flask 提供 /api/rate 路由,校验 3 位货币代码后调用 APIVerve Exchange Rate 接口
currency-converter-python-tutorial — Flask 工具站模板
作者 apiverve
基于 Flask 的货币换算模板,通过 APIVerve 汇率接口在 21 种货币之间按当日汇率换算,同时提供网页界面与命令行工具。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
目前有 1 张原始预览,可打开完整图片查看设计细节。
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
同一套代码包含网页界面与命令行工具 converter.py,二者共用 .env 中的 API 密钥
前端为原生 HTML、CSS、JavaScript,无框架、无构建步骤
API 密钥仅保存在服务端,不发送到浏览器
仓库提供 Vercel 一键部署入口与 .env.example 配置示例
模板详细介绍
这是一个用 Python 与 Flask 编写的货币换算示例项目。网页端由 public/index.html 调用 GET /api/rate?from=USD&to=EUR,app.py 校验两个参数是否为 3 位货币代码后,向 APIVerve 的 Exchange Rate 接口发起请求,把汇率结果返回页面展示;API 密钥保存在服务端,不会下发到浏览器。项目同时附带 converter.py,可在命令行执行换算,例如 python converter.py 100 USD EUR,不带参数运行时会改为交互式提示,读取与网页端相同的 .env 配置。
前端使用原生 HTML、CSS 和 JavaScript,没有框架和构建步骤。依赖仅 flask 与 requests,仓库包含 requirements.txt、.python-version 和 .env.example。运行前需要自行申请 APIVerve API 密钥并写入 .env 的 APIVERVE_API_KEY,本地执行 python app.py 后访问 http://localhost:3000,网页与 API 路由由同一进程提供。项目也可按仓库中的 Vercel 部署按钮一键部署,app.py 会作为 Python 函数运行,public/ 目录由 CDN 提供。
需要注意的限制:接口响应中部分字段属于付费方案,免费方案下返回为空,页面只展示实际拿到的内容;README 说明每个访问者每分钟可发起 10 次请求,该限制保存在内存中,不会在无服务器实例之间共享,因此公开 URL 后他人会消耗你的 API 密钥额度,生产使用需自行加登录、改用共享存储限流或仅由自有后端调用。代码采用 MIT 许可,但演示图片、字体、图标等第三方素材需单独核对许可,域名、托管等外部服务可能另行收费。
适合你的项目吗?
适用场景
- 作为 Flask 调用第三方汇率 API 的最小示例,用于学习服务端转发与密钥保护
- 在旅行或记账类应用中换算费用金额
- 在商店页面按访客所在货币展示价格
- 通过命令行快速完成一次货币换算
适合人群
- 需要 Python 与 Flask 汇率换算起步代码的开发者
- 希望参考服务端代理外部 API、避免密钥暴露的实现方式的人
- 准备把小型 Flask 应用部署到 Vercel 的开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需先注册 APIVerve 获取 API 密钥,并复制 .env.example 为 .env 后填入 APIVERVE_API_KEY
- 2
本地运行:创建虚拟环境、pip install -r requirements.txt、python app.py,然后访问 http://localhost:3000
- 3
命令行使用:python converter.py 100 USD EUR,不带参数运行会进入交互式提示
- 4
部署到 Vercel 时按仓库按钮操作,并在部署过程中填写 APIVERVE_API_KEY
- 5
公开 URL 前需自行处理限流与访问控制,默认每分钟 10 次的限制保存在内存中,不跨无服务器实例共享
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用该模板必须自行注册 APIVerve 并获取 API 密钥,写入 .env 的 APIVERVE_API_KEY 后才能运行网页端与命令行工具。
- APIVerve 汇率接口的部分响应字段仅对付费方案开放,免费方案下这些字段返回为空,页面只展示实际获取到的内容。
- 默认限流为每个访问者每分钟 10 次请求,仅适合演示用途。
- 限流计数保存在内存中,不会在无服务器实例之间共享,公开部署后限流实际效果有限。
- 部署后任何找到该 URL 的人都会消耗你的 API 密钥额度,生产使用需自行加登录、改用共享存储限流或仅由自有后端调用。
- 项目资料提及可选付费版本或功能;本次仅收录公开免费代码,不包含付费升级。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
This template needs an APIVerve API key.
README 原文
Some response fields are for paid plans and come back empty on the free plan.
README 原文
Each visitor can make 10 requests a minute, which is fine for a demo.
README 原文
The limit is kept in memory, so it isn't shared between serverless instances.
README 原文
https://github.com/apiverve/currency-converter-python-tutorial/blob/main/LICENSEhttps://github.com/apiverve/currency-converter-python-tutorial/blob/main/README.mdOnce deployed, anyone who finds your URL can use it on your API key.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 80 / 100
- 技术栈
- Flask
- 网站类型
- 工具站
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-19
- 截图检查日期
- 2026-10-01
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Flask。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 2da0b29d4dbdab9a24cf12878f75f5a38e1478c61bd6bbbef2a51b9d66bc3db8
2026-10-01T02:44:20.384Z
来源文件 / 仓库# Currency Converter | APIVerve Template
[](LICENSE)
[](requirements.txt) [](app.py)
[](https://apiverve.com/marketplace/exchangerate?utm_source=github&utm_medium=template&utm_campaign=currency-converter-python-tutorial)
Convert an amount between 21 currencies at today’s exchange rate. A web app you can deploy, and a command-line tool.
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fapiverve%2Fcurrency-converter-python-tutorial&project-name=currency-converter&repository-name=currency-converter&env=APIVERVE_API_KEY&envDescription=Your%20APIVerve%20API%20key.%20Free%20to%20create%2C%20no%20card%20needed.&envLink=https%3A%2F%2Fdashboard.apiverve.com%2Fsignup%3Fapi%3Dexchangerate%26utm_source%3Dvercel%26utm_medium%3Dtemplate%26utm_campaign%3Dcurrency-converter-python-tutorial)

---
### Get your free API key
This template needs an APIVerve API key. **[Sign up free](https://dashboard.apiverve.com/signup?api=exchangerate&utm_source=github&utm_medium=template&utm_campaign=currency-converter-python-tutorial)**, no credit card required.
---
## Deploy in one click
Click **Deploy with Vercel** above. Vercel copies this repo to your GitHub account, asks for your `APIVERVE_API_KEY`, and gives you a live URL about a minute later.
## Run it locally
1. **Clone the repository**
```bash
git clone https://github.com/apiverve/currency-converter-python-tutorial.git
cd currency-converter-python-tutorial
```
2. **Install the dependencies**
```bash
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
```
3. **Add your API key**
```bash
cp .env.example .env
```
Then open `.env` and set `APIVERVE_API_KEY`.
4. **Start it**
```bash
python app.py
```
5. **Open** `http://localhost:3000`
`python app.py` serves the page and the API route together, so you don't need the Vercel CLI.
## Use it from the command line
```bash
python converter.py 100 USD EUR
```
Run it with no arguments to be prompted instead. It reads the same `.env` as the web app.
## How it works
1. The page (`public/index.html`) calls `GET /api/rate?from=USD&to=EUR`.
2. `app.py` checks both are 3-letter currency codes, then calls Exchange Rate. Your API key stays on the server and never reaches the browser.
3. The page shows the result.
```
├── app.py # Flask app: the /api/rate route, which holds your key
├── apiverve.py # Shared by app.py and converter.py: the key, the APIVerve call, the rate limit
├── converter.py # The command-line version
├── public/ # The page: index.html, app.js, ui.js, style.css
├── requirements.txt # flask, requests
├── .python-version # 3.12, for Vercel
└── .env.example # Copy to .env and add your key
```
### The API call
```python
res = requests.get(
'https://api.apiverve.com/v1/exchangerate',
params={'currency1': 'USD', 'currency2': 'EUR'},
headers={'x-api-key': os.environ['APIVERVE_API_KEY']},
)
data = res.json()['data']
# data['exchangeRate'], data['lastUpdated']
```
Some response fields are for paid plans and come back empty on the free plan. The page shows whatever it gets and leaves the rest out, so it works on every plan.
## Before you share your URL
Once deployed, anyone who finds your URL can use it on your API key. Each visitor can make 10 requests a minute, which is fine for a demo. The limit is kept in memory, so it isn't shared between serverless instances. For production:
- Put the page behind your own sign-in, or
- Move the limit to a shared store such as [Upstash Redis](https://upstash.com/), or
- Call the route only from your own backend.
## Ideas to extend it
- Show prices in the visitor’s currency on a store
- Convert expenses in a travel or accounting app
- Add more currencies: the API accepts any 3-letter code it supports
## API reference
- [Exchange Rate](https://apiverve.com/marketplace/exchangerate?utm_source=github&utm_medium=template&utm_campaign=currency-converter-python-tutorial): `GET https://api.apiverve.com/v1/exchangerate?currency1=¤cy2=`
- [Full documentation](https://docs.apiverve.com?utm_source=github&utm_medium=template&utm_campaign=currency-converter-python-tutorial)
## Tech stack
- **Flask** for the API route, with **requests** to call APIVerve (Python 3.12)
- Plain HTML, CSS and JavaScript for the page: no framework and no build step
- Deploys to Vercel as-is: `app.py` becomes a Python function and `public/` is served from the CDN
## License
MIT. See [LICENSE](LICENSE).
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

airport-distance-python-tutorial
Airport distance calculator template in Python and Flask: distance and flight time between two airports. Deplo…
Flask · 工具站

prettier
Prettier 是一个广受欢迎的开源代码格式化工具,其 GitHub 仓库本身也是一个带有真实在线演示的工具站项目。
Vue · 工具站

OmniTools
OmniTools 是一个基于 React 与 TypeScript 构建的自托管工具站,目标是把日常零散的小工具集中到一个界面里。
React · 工具站

simplemde markdown editor
SimpleMDE 是一个开源的 Markdown 编辑器 JavaScript 组件,定位为 textarea 的替代品。
JavaScript · 工具站

dillinger
Dillinger 是一个基于 Next.js 14 构建的 Markdown 编辑器,核心编辑能力由 Monaco Editor 提供,因此拥有接近 VS Code 的编辑体验。
TypeScript · 工具站

numi
numi 是一款以自然语言输入为核心的计算器工具,用户可以直接输入类似“$20 in euro - 5% discount”或“today + 2 weeks”这样的描述,系统会即时解析并返回结果。
JavaScript · 工具站
