Skip to content
Snippets Groups Projects
Commit 9cc49c98 authored by ARMINGAUD Robin's avatar ARMINGAUD Robin
Browse files

Merge branch 'dev_robin' into 'main'

Dev robin

See merge request !1
parents 07baf03c a7e9efb8
No related branches found
No related tags found
1 merge request!1Dev robin
Pipeline #4366 failed
Showing
with 213 additions and 206 deletions
{
"configurations": [
{
"name": "Flutter",
"program": "lib/main.dart",
"cwd": "app",
"request": "launch",
"type": "dart"
}
]
}
\ No newline at end of file
...@@ -4,89 +4,14 @@ Projet scale Armingaud Robin et Garnier Maxime ...@@ -4,89 +4,14 @@ Projet scale Armingaud Robin et Garnier Maxime
## Getting started ## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps. Le dossier /app contient l'application flutter.
Le dossier /scale server contient le code du serveur flask déployé à l'adresse https://serverscale.herokuapp.com/
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! L'application est constituée de 3 écrans :
- Accueil et login
## Add your files - Profil
- Liste des utilisateurs
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: Les utilisateurs enregistrés sont :
- username : "truc" & password "a"
``` - username : "Brad" & password "a"
cd existing_repo - username : "George" & password "a"
git remote add origin https://gitlab.imt-atlantique.fr/r20armin/appscale.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.imt-atlantique.fr/r20armin/appscale/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.flutter_application_1"> package="com.example.flutter_application_1">
<uses-permission android:name="android.permission.INTERNET"/>
<application <application
android:label="flutter_application_1" android:label="flutter_application_1"
android:name="${applicationName}" android:name="${applicationName}"
......
...@@ -18,7 +18,7 @@ class MyApp extends StatelessWidget { ...@@ -18,7 +18,7 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'AppScale',
theme: ThemeData( theme: ThemeData(
// This is the theme of your application. // This is the theme of your application.
// //
...@@ -29,10 +29,10 @@ class MyApp extends StatelessWidget { ...@@ -29,10 +29,10 @@ class MyApp extends StatelessWidget {
// or simply save your changes to "hot reload" in a Flutter IDE). // or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application // Notice that the counter didn't reset back to zero; the application
// is not restarted. // is not restarted.
primarySwatch: Colors.orange, primarySwatch: Colors.blueGrey,
), ),
routes: { routes: {
LoginScreen.routeName: (context) => LoginScreen(), LoginPage.routeName: (context) => LoginPage(),
DirectoryPage.routeName: (context) => const DirectoryPage(directory: [ DirectoryPage.routeName: (context) => const DirectoryPage(directory: [
Profile( Profile(
"Brad", "Brad",
...@@ -46,8 +46,7 @@ class MyApp extends StatelessWidget { ...@@ -46,8 +46,7 @@ class MyApp extends StatelessWidget {
"George Timothy Clooney (born May 6, 1961) is an American actor and filmmaker. He is the recipient of numerous accolades, including a British Academy Film Award, four Golden Globe Awards, and two Academy Awards, one for his acting and the other as a producer."), "George Timothy Clooney (born May 6, 1961) is an American actor and filmmaker. He is the recipient of numerous accolades, including a British Academy Film Award, four Golden Globe Awards, and two Academy Awards, one for his acting and the other as a producer."),
]) ])
}, },
home: LoginScreen(), home: LoginPage(),
); );
} }
} }
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_application_1/views/directory_page.dart';
import 'package:http/http.dart' as http;
class LoginScreen extends StatelessWidget { Future<void> LoginMethod(String username, String password) async {
var response = await http.post(
Uri.parse('https://127.0.0.1:5000/login'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(
<String, String>{"username": username, "password": password}),
);
static const routeName = '/login-screen'; if (response.statusCode == 200) {
// If the server did return a 200 response,
// then parse the JSON.
print('ok');
} else {
// If the server did not return a 200 response,
// then throw an exception.
throw Exception('Failed to create album.');
}
}
final emailController = TextEditingController(); class Album {
final passwordController = TextEditingController(); final String username;
final String password;
Widget login(IconData icon) { const Album({required this.username, required this.password});
return Container(
height: 50, factory Album.fromJson(Map<String, dynamic> json) {
width: 115, return Album(
decoration: BoxDecoration( username: json['username'],
border: Border.all(color: Colors.grey.withOpacity(0.4), width: 1), password: json['password'],
borderRadius: BorderRadius.circular(12),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 24),
TextButton(onPressed: () {}, child: Text('Login')),
],
),
); );
} }
}
Widget userInput(TextEditingController userInput, String hintTitle, TextInputType keyboardType) { class LoginPage extends StatefulWidget {
return Container( static const routeName = '/login-page';
height: 55,
margin: EdgeInsets.only(bottom: 15), const LoginPage({Key? key}) : super(key: key);
decoration: BoxDecoration(color: Colors.blueGrey.shade200, borderRadius: BorderRadius.circular(30)),
child: Padding( @override
padding: const EdgeInsets.only(left: 25.0, top: 15, right: 25), State<LoginPage> createState() => _LoginPageState();
child: TextField(
controller: userInput,
autocorrect: false,
enableSuggestions: false,
autofocus: false,
decoration: InputDecoration.collapsed(
hintText: hintTitle,
hintStyle: TextStyle(fontSize: 18, color: Colors.white70, fontStyle: FontStyle.italic),
),
keyboardType: keyboardType,
),
),
);
} }
class _LoginPageState extends State<LoginPage> {
late String pseudo;
late String password;
final _formKey = GlobalKey<FormState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
body: Container( appBar: AppBar(title: const Text('Login')),
child: Column( body: Padding(
mainAxisAlignment: MainAxisAlignment.end, padding: const EdgeInsets.all(60),
children: [ child: Center(
Container( child: Form(
height: 510, key: _formKey,
width: double.infinity, child: Column(children: [
decoration: BoxDecoration( TextFormField(
color: Colors.white, onChanged: (value) {
borderRadius: BorderRadius.only(topLeft: Radius.circular(15), topRight: Radius.circular(15)), setState(() {
pseudo = value;
});
},
decoration: const InputDecoration(
icon: Icon(Icons.person),
labelText: 'Pseudo *',
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
},
),
TextFormField(
onChanged: (value) {
setState(() {
password = value;
});
},
decoration: const InputDecoration(
icon: Icon(Icons.key),
labelText: 'Password *',
),
obscureText: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
}
},
), ),
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 45),
userInput(emailController, 'Email', TextInputType.emailAddress),
userInput(passwordController, 'Password', TextInputType.visiblePassword),
Container( Container(
height: 55, margin: const EdgeInsets.only(top: 30.0),
// for an exact replicate, remove the padding. child: ElevatedButton(
// pour une réplique exact, enlever le padding. onPressed: () {
padding: const EdgeInsets.only(top: 5, left: 70, right: 70), if (_formKey.currentState!.validate()) {
LoginMethod(pseudo, password);
}
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.fromLTRB(40, 15, 40, 15),
), ),
SizedBox(height: 20), child: const Text(
Center(child: Text('Forgot password ?'),), 'Login',
SizedBox(height: 20), style: TextStyle(
Padding( fontWeight: FontWeight.bold,
padding: const EdgeInsets.only(top: 25.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
login(Icons.add),
login(Icons.book_online),
],
), ),
), ),
Divider(thickness: 0, color: Colors.white),
],
), ),
), ),
]),
), ),
],
), ),
), ),
); );
......
...@@ -74,6 +74,20 @@ packages: ...@@ -74,6 +74,20 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
lints: lints:
dependency: transitive dependency: transitive
description: description:
...@@ -156,6 +170,13 @@ packages: ...@@ -156,6 +170,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.9" version: "0.4.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
......
...@@ -30,6 +30,8 @@ dependencies: ...@@ -30,6 +30,8 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
http: ">=0.13.4 "
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
......
.vercel
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
# syntax=docker/dockerfile:1
FROM python:3.8-slim-buster
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt
COPY . .
EXPOSE 5000
CMD [ "python3", "app.py"]
web: gunicorn main:app 0.0.0.0:$PORT
\ No newline at end of file
No preview for this file type
File added
import os
from flask import Flask, jsonify, request from flask import Flask, jsonify, request
from werkzeug.security import check_password_hash from werkzeug.security import check_password_hash
from database.database import db, init_database from database.database import db, init_database
...@@ -16,11 +18,11 @@ with app.app_context(): ...@@ -16,11 +18,11 @@ with app.app_context():
def hello_world(): def hello_world():
return login() return login()
@app.route('/login', methods=['POST'])
def login():
username = request.args.get('username') #Je sais pas trop si c'est exploitable du coté client
password = request.args.get('password') #pareil du coup, y faudra peut-être modifier ça
@app.route('/login', methods=['POST', 'GET'])
def login():
username = request.form.get('username')
password = request.form.get('password')
user = models.User.query.filter_by(username=username).first() user = models.User.query.filter_by(username=username).first()
# check if the user actually exists # check if the user actually exists
...@@ -58,6 +60,7 @@ def populate(): ...@@ -58,6 +60,7 @@ def populate():
return jsonify(data) return jsonify(data)
''' '''
port = int(os.environ.get("PORT", 5000)) # <-----
app.run(host='0.0.0.0', port=port)
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.run(host='0.0.0.0',port=port)
File added
File added
No preview for this file type
Flask==2.0.2
Flask_Login==0.5.0
Flask_SQLAlchemy==2.5.1
Werkzeug==2.0.2
gunicorn==20.1.0
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment