Flask

Flask import CSV into pandas df

雨燕双飞 提交于 2021-01-29 11:21:42
问题 I am attempting to create an app where the user could click a button to upload a CSV file into Pandas (hoping to do more in pd if I can get this work) and then display the data. Can someone give me a tip? I apologize in advance if its basic stuff, there isnt a lot of wisdom here: app.py from flask import Flask, make_response, request import pandas as pd app = Flask(__name__) @app.route('/') def form(): return """ <html> <body> <h1>Economizer Diagnostics</h1> <form action="/transform" method=

How to make html markup show up? [duplicate]

自作多情 提交于 2021-01-29 10:55:55
问题 This question already has answers here : Passing HTML to template using Flask/Jinja2 (6 answers) Closed 1 year ago . so I am new to HTML. I am building a web app with flask. I am trying to visualise some HTML markup, but it doen't show up properly. I have the following flask route: @app.route('/predict',methods=['GET','POST']) def api(): if request.method == "POST": input_data = request.form['rawtext'] output_data = model_api(input_data) alignedText = output_data["words"] predictions = output

`flask db migrate` error

ぃ、小莉子 提交于 2021-01-29 10:47:26
问题 We are trying to run a flask db migrate and flask db upgrade which throws the following error: Usage: flask db upgrade [OPTIONS] [REVISION] Error: The file/path provided (C) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py We have added the app's directory to the PYTHONPATH environment variable but still get the error. Any help would be appreciated. Below is our __init__.py code. Are we missing something? import logging from

Decode JSON in flask

若如初见. 提交于 2021-01-29 10:31:03
问题 i want to send JSON format data in my flask app using AJAX call, when i send it i got "None" in flask. here is jquery, $('#form').on('click',function(){ var text = $('#textField').val(); var obj = {name:text}; var myJSON = JSON.stringify(obj); $.ajax({ data : myJSON, url: '/process', type : 'post', contentType: 'application/json', dataType : 'json' }) }) here is my Flask route, @app.route('/process',methods=["POST"]) def process(): data = request.json return render_template("form.html",data =

Creating a sqlite database connection for a flask app

百般思念 提交于 2021-01-29 10:20:08
问题 I am working on a web back-end which reads from a database file, processes the data and returns a json object. I am not really informed about flask and the way the variables life in a flask app. As you can see below, i am calling the flaskApp from a wsgi file. I created the "get_db()" function according to the flask documentation, but there is no improvement by using this function. Is there a way to connect to the database only once and not every time the URL is called? #file flaskApp.py #!

change event on multiselect does not trigger

不想你离开。 提交于 2021-01-29 10:16:23
问题 Edit: Problem solved! I have several multiselect fields in flask. When I change the selected items in one, I want to trigger a change in the other ones (right now, I am only trying to change one other field, because I don't know how to change several). However, this does not work at all. When I change the selected items, nothing changes, I don't even get an error message. Is a .change event not the right one to use with multiselect? My multiselect field looks like this: and I am using this

TypeError: 'NoneType' object is not subscriptable in Flask, mysql application

故事扮演 提交于 2021-01-29 10:13:43
问题 I am creating a login application using Flask-mysql. from flask import Flask, jsonify, request, json from flask_mysqldb import MySQL from datetime import datetime from flask_cors import CORS from flask_bcrypt import Bcrypt from flask_jwt_extended import JWTManager from flask_jwt_extended import (create_access_token, create_refresh_token, jwt_required, jwt_refresh_token_required, get_jwt_identity, get_raw_jwt) import yaml app = Flask(__name__) alogin = yaml.load(open('alogin.yaml')) app.config

400 Bad request when uploading image to Google Cloud storage using Python 3 Flask

断了今生、忘了曾经 提交于 2021-01-29 09:48:52
问题 I'm trying to upload a image to cloud storage using blob.upload_from_string but I get a 400 Bad Request Error I'm following this tutorial, but the difference is that I want to send a string instead of a file, and the string contains the image. This is the function : def upload_image_file(self, file): """ Upload the user-uploaded file to Google Cloud Storage and retrieve its publicly-accessible URL. """ if not file: return None testImageString = "Python is interesting." arr = bytes

Is there a way to login a user using Flask Socket IO?

独自空忆成欢 提交于 2021-01-29 09:43:57
问题 I'm using Flask with Flask SocketIO and Flask Login . My issue is that when I tried to use the login_user function inside of a socketio.on event, there is no error, but the user isn't logged in. My example might help illustrate this. my example event will be called for the user to login, and then /usersonly will be for after that event is called. @socketio.on('my example event') def my_func(json): ... login_user(user) @app.route('/usersonly') @login.user_required def my_call(): print(current

Python arabic text returns in right-to-left orientation instead of left-to-right

此生再无相见时 提交于 2021-01-29 09:39:21
问题 I'm working on a python project with Python(3.6) and Flask in which I have to return a text in Arabic. When I print the text in the console it works well but when I return it as response it's order changes to right-to-left. Here's what I have tried: from odoa import ODOA import arabic_reshaper from bidi.algorithm import get_display from flask import Flask import json app = Flask(__name__) app.config['JSON_AS_ASCII'] = False @app.route('/', methods=['GET']) def get_an_ayah(): odoa = ODOA()