Задать вопрос
  • Не выводятся данные eel / pyowm?

    IM_NIK
    @IM_NIK Автор вопроса
    Код после решения
    main.py
    # imports
    import eel 
    import pyowm
    # api key
    owm = pyowm.OWM ( '80e8e723ef945c291f4661f5898f93e0',language = "RU" )
    @eel.expose
    def get_weather(place):
        #owm
        observation = owm.weather_at_place(place)
        Observation = weather = observation.get_weather()
        #temp
        Temp = weather.get_temperature('celsius')['temp']
        #status
        Status = weather.get_detailed_status()
        return "В городе "+place+'температура '+str(Temp) + Status
    
    #eel
    eel.init("web")
    eel.start("main.html", size=(500 , 500))

    main.html
    <!DOCTYPE html>
    <html lang="ru">
    <head>
        <meta charset="UTF-8">
        <title>find weather</title>
        <script src="eel.js"></script>
        <link rel="stylesheet" href="app.css">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
        <link rel="icon" type ="image/png" href="weather-icon.png">
    </head>
    <body>
    <div class="header">
        <img src="weather-icon.png" height="60px">
        <h2>find weather</h2>
    </div>
    <div class="form">
        <form>
            <input id='location' class="enter" type="text" placeholder="Введите название города" value="москва">
        </form>
    </div>
    <div class="butt">
        <button id='show'>Найти</button>
    </div>
    <div id="info"></div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script type="text/javascript">
        async function display_weather(){
            let place = document.getElementById('location').value;
            
            let res = await eel.get_weather(place)();
            document.getElementById('info').innerHTML = res;
            }
            jQuery('#show').on('click',function(){
                //
                display_weather();
            });
        </script>
    </body>
    </html>
    Ответ написан
    Комментировать
  • Не создаётся база данных SQLite python?

    IM_NIK
    @IM_NIK Автор вопроса
    делал всё по этому уроку
    https://www.youtube.com/watch?v=G-si1WbtNeM
    База не создалась после полной переделки блока и проверки на помарки .

    app.py
    from flask import Flask , request,redirect , url_for
    from configurasion import  Configuration
    from flask_sqlalchemy import SQLAlchemy
    from datetime import datetime
    #!!! file
    app = Flask(__name__)
    app.config.from_object(Configuration)
    db=SQLAlchemy(app)

    main.py
    from app import db
    from app import app
    import view
    if __name__ == "__main__":
        app.run()

    view.py
    from app import app
    from flask import render_template
    from models import Article
    
    @app.route("/",methods=['POST','GET'])
    def index():
    	return render_template('test.html')
    	if request.method == 'POST':
    		pass
    		title = request.form['title']
    		text = request.form['text']
    		article = Post(title=title,text=text)
    		try:
    			db.session.add(article)
    			db.session.commit()
    			return redirect('/')
    		except:
    			return render_template('404.html'),404
    	else:
    		return render_template('test.html')
    @app.route("/snq")
    def snq():
    	return "SNQ OLEG MOLCHANOV"
    @app.route("/ADMIN")
    def admin():
    	return render_template('ADMIN.html')
    @app.errorhandler(404)
    def page_not_faund(e):
    	return render_template('404.html'),404
    @app.route('/comment',methods=['POST','GET'])
    def comment():
    	articles = Article.query.order_by(Article.date).all()
    	return render_template('Comment.html',articles=articles)

    Configurasion,py
    class Configuration():
    	DEBUG=True;
    	SQLALCHEMY_TRACK_MODIFICATIONS = False
    	SQLALCHEMY_DATEBASE_URI = 'sqlite:///blog.db'

    models.py
    from app import db
    from datetime import datetime
    import re
    
    class  Article(db.Model):
    	# SETTINGS
    	__tablename__ = 'posts'
    	id = db.Column(db.Integer,primary_key=True)
    	title = db.Column(db.String(140) ,nullable=False)
    	text = db.Column(db.Text , nullable=False)
    	date = db.Column(db.DateTime, default=datetime.utcnow)
    	#funcshon
    	def  __repr__(self):
    		return '<Article %r>' % self.id
    
    db.create_all()
    ПОМОГИТЕ ПОЖАЛУЙСТА!!!
    Ответ написан