Multiple api at one vm
Hi I have azure vm with linux I want to create multiple APIs with flask and each api have his own venv with derren python version, can I do that ?
/r/flask
https://redd.it/1eu5048
DjangoCon US: anyone looking to share hotel/airbnb?
I’m looking for a room share, either in a hotel or Airbnb, as there aren’t many feasible options available at the moment. I’ll be in town from September 21 until early morning on September 29.
Please let me know if you have space or any leads!
/r/django
https://redd.it/1euppvm
[P] Updates on OpenCL backend for Pytorch
I develop [the OpenCL backend for pytorch](https://github.com/artyom-beilis/pytorch_dlprim) - it allows to train your networks on AMD, NVidia and Intel GPUs on both Windows and Linux. Unlike cuda/cudnn based solution - it is cross platform and fully open source.
Updates:
1. With an assistance from pytorch core developers now pytorch 2.4 is supported
2. Now it is easy to install it - I provide now prebuild packages for Linux and Windows - just install whl package and you are good to go
3. Lots of other improvements
How do you use it:
- Download whl file from project page according to operating system, python version and pytorch version
- Install CPU version of pytorch and install whl you downloaded, for example `pytorch_ocl-0.1.0+torch2.4-cp310-none-linux_x86_64.whl`
- Now just `import pytorch_ocl` and now you can train on OpenCL `ocl` devices: `torch.randn(10,10,dev='ocl:2')
How is the performance: while it isn't as good as native NVidia cuda or AMD rocm it still gives [reasonable performance](https://github.com/artyom-beilis/pytorch_dlprim/blob/master/benchmark.md) depending on platform, network - usually around 60-70% for training and 70-80% for inference.
/r/MachineLearning
https://redd.it/1euamk8
Best way to add user auth
Hi, just wondering what the best way would be to add authentication - login signup etc to Django. I’ve seen Django allauth and Djangos built in auth. Is there any others, and is it worth using allauth or should I stick with built in auth.
I will need in the future the ability to pair some social accounts.
/r/django
https://redd.it/1eudcxx
Black-Scholes model calculator
My black scholes model calculator is a website that allows for people to input data, manually or through a ticker, to analyze different premium cost at different strike prices.
* **What My Project Does:** My website allows users to calculate the premiums of calls and puts in option trading. It also allows for users to analyze data through a heat map, input a stock to see different premium cost, and to download some data.
* **Target Audience**: My target audience would be students who want to study the model and for traders to make more informed financial decisions
* **Comparison** This project has a heat map and the option to put in your own stock, which is harder to find on other calculators. It wasn’t made to compare though, but rather as just another tool to use.
Source Code: https://github.com/erikhox/blackscholes
Website: https://options-erik.streamlit.app
/r/Python
https://redd.it/1etz65g
Flask-SQLAlchemy foreign key constraints
I'm using a GPT-4 plugin that's supposed to have it's knowledge up to date with flask and flask-sqlalchemy, and it told me this
> SQLite does not enforce foreign key constraints by default, so you might want to ensure that foreign key support is enabled when the connection is created. This can be done by adding the following configuration setting:
>
>
> app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {'connect_args': {'foreign_keys': 'ON'}}
>
TypeError: 'foreign_keys' is an invalid keyword argument for Connection()
foreign_keys
in SQLite when using Flask-SQLAlchemy because SQLite's foreign key enforcement is enabled by default in SQLAlchemy if you use the ForeignKey
construct correctly in your models. Am I doing models wrong?
I'm working on a Flask project, and as it currently sits I'm getting a circular import error with my init_db method. If I break the circular import, then the init_db works but doesn't input 2 cells in related tables.
Here's the file structure:
```bash
├── app
│ ├── extensions
│ │ ├── errors.py
│ │ └── sqlalchemy.py
│ ├── index
│ │ ├── __init__.py
│ │ └── routes.py
│ ├── __init__.py
│ ├── models
│ │ ├── events.py
│ │ ├── users.py
│ │ └── vendors.py
│ ├── static
│ │ ├── favicon.ico
│ │ └── style.css
│ └── templates
│ ├── base.html
│ ├── errors
│ │ ├── 404.html
│ │ └── 500.html
│ ├── index.html
│ └── login.html
├── app.db
├── config.py
├── Dockerfile
├── init_db.py
├── LICENSE
├── README.md
└── requirements.txt
```
init_db.py
```python
#! python3
# -*- coding: utf-8 -*-
"""init_db.py.
This file is used to initialize the database.
"""
from datetime import date
from app import create_app
from app.extensions.sqlalchemy import db
from app.models.events import Event
from app.models.users import User
from app.models.vendors import Vendor
app = create_app()
@app.cli.command()
def initdb():
'''Create the database, and setup tables.'''
db.create_all()
vendor1 = Vendor(name='Test Corp',
/r/flask
https://redd.it/1etbm75
Help me choose CMS
I was searching for good CMS which can go along with Django. I came across three famous options:
Django CMS
Wagtail
Mezzanine
/r/django
https://redd.it/1etk9yc
Ngnix Reverse Proxy Gunicorn HTTPS TLS and Django
Is anyone using Ngnix Reverse Proxy and Gunicorn HTTPS TLS to encrypt the backend? Or is this even supported? Or maybe everyone terminates TLS at Nginx and plaintext on the backend?
If so, do you have an example of your gunicorn.conf.py file showing what is needed? The Gunicorn settings dont tell you what is required.
/r/django
https://redd.it/1ethcrf
Moonglow: Start and stop remote iPython servers from VSCode
Hi all - wanted to post about my project Moonglow here as I thought it might be interesting to people!
It's a VSCode extension that lets you start and stop remote servers without leaving your editor. Right now you can connect to Runpod and AWS; the extension will take care of starting and stopping the remote instances, and will also set up the connection from your iPython notebook to the remote kernel.
Here's demo video of how it works! You can check it out at http://moonglow.ai .
https://reddit.com/link/1et9qx6/video/f5egjtcrvwid1/player
/r/IPython
https://redd.it/1et9qx6
Documentation style?
Hi, im very new to django, trying to learn and understand but im lost and dont know where or what to search for.
I want my page to look like documentation style. I know you can get wiki style ( django-wiki etc.) but im interested to have documentation style but with ability to jump between languages and log in and create pages, write text, add pics, etc.. Im speaking multiple languages so my project will involve multiple languages so this is the reason for language selector. Like FreeBSD docs or close to Django docs. Is there a package like this ?? I tried to look for django doc app but im going nowhere as every time i use doc/docs im just getting to documentation pages.
Thank You!
/r/django
https://redd.it/1etdknx
website like hacker rank
Hi, im trying to create a website like hacker rank, i mean where student can solve set of python questions
i managed to get the solution to the backend,
i have no idea what to do after,
found some resource pointing to docker sdk,
i'm not actually understanding how to get along with it,
also hacker rank has this test cases right?
where we need to pass all test cases to complete a problem
i want to make someting like that,,,
but all together i have no idea how all this together works.,,
please educate me if you can...
or share resource that may help..
/r/djangolearning
https://redd.it/1et4p8t
VikingCRM - CRM for small to medium sized businesses
I'm launching my new CRM system built in Python Flask, HTML / JS / CSS on September 2nd.
I have been working on this project for about 5.5 months and it has integrations to: Gmail, Outlook, LinkedIn, WooCommerce, Stripe, Mailgun & Fortnox (Swedish bookkeeping software).
If you have any advice on functions to add or UI every suggestion is welcome :)
https://preview.redd.it/wmgh4q892uid1.png?width=1880&format=png&auto=webp&s=2d5b09c0c5e1bbb3f3cf53edbeaf801dd895fdc2
https://preview.redd.it/8sogoq892uid1.png?width=1901&format=png&auto=webp&s=24aecdf6b8bd7c1b39a051820c35209b0b39bea6
https://preview.redd.it/pp38nq892uid1.png?width=1898&format=png&auto=webp&s=123d4c92caec39ee5c0a82b2b0713499288e2293
https://preview.redd.it/ouprfq892uid1.png?width=1898&format=png&auto=webp&s=ab41bf158cb4c787055903013865fdce7a7416a2
https://preview.redd.it/umkxkr892uid1.png?width=1898&format=png&auto=webp&s=eaaef12eb4e59535eff75278b16f511b81e20403
https://preview.redd.it/akugrr892uid1.png?width=1898&format=png&auto=webp&s=16dffb718c98c9c6c5501f7b2bb0e5ab465fc3a4
https://preview.redd.it/kroprr892uid1.png?width=1898&format=png&auto=webp&s=2b34d3bb26cce1c46b5eaf62cbbf4fe39d0f5c46
/r/flask
https://redd.it/1esvud0
R I've devised a potential transformer-like architecture with O(n) time complexity, reducible to O(log n) when parallelized.
[R\] I've attempted to build an architecture that uses plain divide and compute methods. From what I can see and understand, it seems to work, at least in my eyes. While there's a possibility of mistakes in my code, I've checked and tested it without finding any errors.
I'd like to know if this approach is anything new. If so, I'm interested in collaborating with you to write a research paper about it. Additionally, I'd appreciate your help in reviewing my code for any potential mistakes.
But most most importantly I want to know about the architecture ,is it new, has anyone has tried this or something similar ,
I've written a Medium article that includes the code. The article is available at: DakshishSingh/equinox-architecture-divide-compute-775a8ff698fe">DakshishSingh/equinox-architecture-divide-compute-775a8ff698fe" rel="nofollow">https://medium.com/@DakshishSingh/equinox-architecture-divide-compute-775a8ff698fe
Your assistance and thoughts on this matter would be greatly appreciated. If you have any questions or need clarification, please feel free to ask.
/r/MachineLearning
https://redd.it/1esteqd
CodeChef Starters 147 Solutions | Gold Coins | Independence Day | Non-Pr...
https://youtube.com/watch?v=kR84dGTJpdE&si=UJSStWVZeT0zZueC
/r/IPython
https://redd.it/1eso416
Pythonanywhere —> Azure?
I am testing a flask api, that’s exposed to the internet, on pythonanywhere.
If I need to move it to something that’s on “azure” (for enterprise reasons), may I ask what’s the right service, and that’s hopefully low cost, to use on Azure? Thank you!
/r/flask
https://redd.it/1eu56yr
confession wall
Source code: https://github.com/IdanHajbeko/Confession-Wall
website: **https://unified-first-rooster.ngrok-free.app/**
What My Project Does
My Python application hosts a website where people can post confessions anonymously.
Target Audience
Anyone who wants to post confessions anonymously or learn about backend development with python
/r/flask
https://redd.it/1eu2fqu
Old parameters being processed
In my app I have an HTML table showing values on one of my Flask app pages. The values are being stored in a simple list: prediction_list=[]
I want to be able to clear the table, but it seems very inconsistent; sometimes it will clear the values on the page, other times nothing happens, even though the list object is showing as empty in my logging/console output.
Possibly it's a caching thing in the browser, but is there anything I'm doing wrong here?
@app.route('/predictions/',methods=('GET', 'POST'))
def predictions():
if request.method == 'POST':
# This bit seems to work fine... calls a "predict" function and adds a row to the predictions table
if request.form'action' == 'predict':
home = request.form'home'
away = request.form'away'
/r/flask
https://redd.it/1eugz2t
Whole website shows 404
This morning, I made a database change to my app mapping users to game objects which was fine. I then created an initial user, which was fine but I realised I wanted the user to be created alongside an initial game object. So I deleted the user from my database, manually. After that everything went to shit.
I started getting a 404 error on every page. I've uninstalled and reinstalled the venv multiple times now. I've cleared all caches on my browser and I've looked through all my code.
I really have zero idea what is going on here. Any advice will be well received and I will answer any clarification questions.
FIXED: Leaving this here in case any else ever comes across this issue. The problem seems to have been coming from this bit of code so I cleared my cookies and this fixed the issue.
@login_manager.user_loader
def load_user(user_id):
return db.get_or_404(User, user_id)
/r/flask
https://redd.it/1euehn3
Saturday Daily Thread: Resource Request and Sharing! Daily Thread
# Weekly Thread: Resource Request and Sharing 📚
Stumbled upon a useful Python resource? Or are you looking for a guide on a specific topic? Welcome to the Resource Request and Sharing thread!
## How it Works:
1. Request: Can't find a resource on a particular topic? Ask here!
2. Share: Found something useful? Share it with the community.
3. Review: Give or get opinions on Python resources you've used.
## Guidelines:
Please include the type of resource (e.g., book, video, article) and the topic.
Always be respectful when reviewing someone else's shared resource.
## Example Shares:
1. Book: "Fluent Python" \- Great for understanding Pythonic idioms.
2. Video: Python Data Structures \- Excellent overview of Python's built-in data structures.
3. Article: Understanding Python Decorators \- A deep dive into decorators.
## Example Requests:
1. Looking for: Video tutorials on web scraping with Python.
2. Need: Book recommendations for Python machine learning.
Share the knowledge, enrich the community. Happy learning! 🌟
/r/Python
https://redd.it/1eu3yfn
confession wall
Source code: https://github.com/IdanHajbeko/Confession-Wall
website: **https://unified-first-rooster.ngrok-free.app/**
What My Project Does
My Python application hosts a website where people can post confessions anonymously.
Target Audience
Anyone who wants to post confessions anonymously or learn about backend development with python
/r/Python
https://redd.it/1etrcqs
Managing Multiple OAuth Providers
Let's say I have two OAuth providers, Google and GitHub with which user can create an account in my Django application. I wrote a custom user model and a custom model for storing OAuth details (provider and user ID from provider etc.).
Let's say the user logs-in with GitHub first and creates an account. He logs out, signs-up again, but this time with Google. Now what happens? How can I know that the user already has an account linked with GitHub? I cannot check the email because their email can be different for different platforms. I cannot use the ID of the user from OAuth provider too.
Please do not ask me to use libraries, I'm willing to learn how to implement it on my own.
/r/django
https://redd.it/1etk2pt
SpotAPI: Spotify API without the hassle!
Hello everyone,
I’m thrilled to introduce SpotAPI, a Python library designed to make interacting with Spotify's APIs a breeze!
What My Project Does:
SpotAPI provides a Python wrapper to interact with both private and public Spotify APIs. It emulates the requests typically made through a web browser, enabling you to access Spotify’s rich set of features programmatically. SpotAPI uses your Spotify username and password to authenticate, allowing you to work with Spotify data right out of the box—no additional API keys required!
Features:
- Public API Access: Easily retrieve and manipulate public Spotify data, including playlists, albums, and tracks.
- Private API Access: Explore private Spotify endpoints to customize and enhance your application as needed.
- Ready to Use: Designed for immediate integration, allowing you to accomplish tasks with just a few lines of code.
- No API Key Required: Enjoy seamless usage without needing a Spotify API key. It’s straightforward and hassle-free!
- Browser-like Requests: Accurately replicate the HTTP requests Spotify makes in the browser, providing a true-to-web experience while staying under the radar.
Target Audience:
SpotAPI is ideal for developers looking to integrate Spotify data into their applications or anyone interested in experimenting with Spotify’s API. It’s perfect for both educational purposes and personal projects where ease of
/r/Python
https://redd.it/1etgwc9
Elastic Beanstalk vs EC2 Autoscaling for Django
I'm currently using EC2 autoscaling. Do you think EB is a better choice for Django? does it simplify deployment process? I'm curious if EB allows users to set max instance like EC2 autoscaling.
/r/djangolearning
https://redd.it/1eta9wq
Friday Daily Thread: r/Python Meta and Free-Talk Fridays
# Weekly Thread: Meta Discussions and Free Talk Friday 🎙️
Welcome to Free Talk Friday on /r/Python! This is the place to discuss the r/Python community (meta discussions), Python news, projects, or anything else Python-related!
## How it Works:
1. Open Mic: Share your thoughts, questions, or anything you'd like related to Python or the community.
2. Community Pulse: Discuss what you feel is working well or what could be improved in the /r/python community.
3. News & Updates: Keep up-to-date with the latest in Python and share any news you find interesting.
## Guidelines:
All topics should be related to Python or the /r/python community.
Be respectful and follow Reddit's Code of Conduct.
## Example Topics:
1. New Python Release: What do you think about the new features in Python 3.11?
2. Community Events: Any Python meetups or webinars coming up?
3. Learning Resources: Found a great Python tutorial? Share it here!
4. Job Market: How has Python impacted your career?
5. Hot Takes: Got a controversial Python opinion? Let's hear it!
6. Community Ideas: Something you'd like to see us do? tell us.
Let's keep the conversation going. Happy discussing! 🌟
/r/Python
https://redd.it/1etajo2
Issue with django-cors-headers
Hi Guys!
I have an issue with django-cors-headers. I tried any solution i could find but still got an error.
I am working on a React/Django Project (with DRF) - both are running on my localhost on different ports. Everything works fine when i am on my machine but as soon as i switch to my virtual machine (different ip for testing cors) i get following error:
https://preview.redd.it/wyai4vpa3wid1.png?width=860&format=png&auto=webp&s=b72fc50661ca5c3b37918ac1dea4f93ec725b934
I dont understand why this still keeps happening after i checked everything.
My settings.py
...
ALLOWEDHOSTS = ["*"]
INSTALLEDAPPS =
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"rest_framework",
"api",
"corsheaders",
"djoser",
MIDDLEWARE =
/r/django
[https://redd.it/1et62ja
Personal highlights from PyCon US 2024?
Now that most of the videos from PyCon US have been uploaded https://youtube.com/playlist?list=PL2Uw4_HvXqvYhjub9bw4uDAmNtprgAvlJ&si=iaO7Vs1VaZj5Cn3W, does anyone have any particular favourites from this year?
I’ve personally really enjoyed the videos on Functional Python and pydantic a lot!
/r/Python
https://redd.it/1et20on
Use cases where a mutable default argument is warranted?
Consider the following very simple script (just to demonstrate what I’m talking about)
def append_len(list_in: list = []) -> None:
list_in.append(len(list_in))
print(list_in)
x = []
append_len()
append_len()
append_len(x)
append_len(x)
The output is
[0]
[0, 1]
[0]
[0, 1]
Pretty pointless here, but are there cases people have found where it’s *useful* to define a mutable default argument like this, rather than a default value of `None` and setting to `[]` (or some other mutable object) in the body of the function?
/r/Python
https://redd.it/1eskrri
ImageRevise - Resize, Watermark, EXIF remove, and compress images!
**What My Project Does**
[ImageRevise](https://github.com/Thymester/ImageRevise/releases/tag/Initial) is a somewhat feature-rich image processing application designed to simplify tasks such as resizing, watermarking, optimizing, and managing image metadata. Key features include:
* **Resize Images**: Adjust dimensions with options to maintain aspect ratio or specify custom sizes.
* **Add Watermarks**: Customize and place watermarks at various positions with adjustable sizes.
* **Optimize Images**: Reduce file sizes for web use while maintaining quality.
* **Remove Metadata**: Eliminate EXIF data to enhance privacy and manage file information.
* **Preview Changes**: See a live preview of image modifications before saving.
**Target Audience**
This is for users who want to resize, watermark, remove metadata, and compress/resize their images. It is also a project that I wanted to do to help build my Python skills.
**Comparison**
My Python image tool stands out from other image-processing tools for a few reasons:
1. **Custom Watermark Positioning**: Unlike many tools that offer basic watermarking, my tool allows users to place watermarks at various positions (center, bottom right, bottom left, top right, top left), giving you more control over the watermark’s placement.
2. **Flexible Resizing Options**: my tool can resize images while maintaining the original aspect ratio, and it supports multiple size presets (Small, Medium, Large). This flexibility benefits users who need to resize images
/r/Python
https://redd.it/1esjwv3
Django ASGI on Vercel
How do I deploy a django asgi app using daphne on vercel or it's not possible ?
/r/django
https://redd.it/1esrnv9