python - 如何在从 python Flask 服务器获取的 expo react-native 应用程序上显示图像
问题描述
从我的 expo 应用程序中,我想向服务器发出请求。代码如下所示:
fetch('http://caiofernandes.pythonanywhere.com/')
.then(res => {
console.log(res)
})
.catch(error => console.log(error))
我的烧瓶服务器应该以图像响应。
from flask import Flask
from flask_cors import CORS, cross_origin
from flask import send_file
app = Flask(__name__)
CORS(app)
@app.route('/')
@cross_origin()
def hello_world():
return send_file('test100.png', mimetype='image/png')
如何显示我的服务器返回的图像?
解决方案
推荐阅读
- pascal - 在 Object pascal 中计算字符串中的不同字符
- javascript - 为什么我的 Bootstrap 手风琴不能正常工作?
- python-3.x - 使用 cython 时出错“致命错误 C1083;无法打开包含文件:'io.h':没有这样的文件或目录”
- swift - 在 Swift 中异步合并两个字典
- c++ - 如何将int转换为字符串?
- angular - Nativescript - 装饰器不支持错误函数调用,但调用了“NativeScriptRouterModule”
- java - 如何使用 Spring Boot 将 @Cacheable 与 redis 一起使用
- nginx - 反向代理到两个单独的 nginx 实例
- node.js - 如何配置 rollupJs 将 nodeJs 脚本转换为 es6 模块?
- javascript - 在JS中使用按钮点击制作变量